From 7c19d6c0efd419bf36bd3d2c4838bdd04d147b90 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Thu, 13 Aug 2015 00:20:15 +0100 Subject: [PATCH] First twelve OOP challenges ready to roll --- ...t-oriented-and-functional-programming.json | 175 +++++++++++++----- 1 file changed, 127 insertions(+), 48 deletions(-) diff --git a/seed/challenges/object-oriented-and-functional-programming.json b/seed/challenges/object-oriented-and-functional-programming.json index ac85a3d5ac..218496ddbf 100644 --- a/seed/challenges/object-oriented-and-functional-programming.json +++ b/seed/challenges/object-oriented-and-functional-programming.json @@ -123,7 +123,8 @@ "difficulty":0, "description":[ "", - "Instantiation at it's most basic level is where you are creating a copy of an object from a template for use at a later time" + "Instantiation at it's most basic level is where you are creating a copy of an object from a template for use at a later time", + "The instance inherits all the properties and methods of the original Object" ], "tests":[ "assert((new Car()).wheels === 4, 'The property wheels should be four in the object constructor');", @@ -145,48 +146,30 @@ ], "challengeType":1 }, - { - "id":"cf1111c1c15feddfaeb5bdef", - "title":"Waypoint: Inheritance", - "difficulty":0, - "description":[ - "" - ], - "tests":[ - "assert(1==2, '');" - ], - "challengeSeed":[ - "Under Construction" - ], - "challengeType":1 - }, - { - "id":"cf1111c1c15feddfaeb6bdef", - "title":"Waypoint: Prototypical Inheritance", - "difficulty":0, - "description":[ - "" - ], - "tests":[ - "assert(1==2, '');" - ], - "challengeSeed":[ - "Under Construction" - ], - "challengeType":1 - }, { "id":"cf1111c1c15feddfaeb7bdef", "title":"Waypoint: Using .map", "difficulty":0, "description":[ - "" + "", + "array = array.map(function(val){", + " return(val+1);", + "});", + "", + "The map method is one of the easiest ways to iterate through an array or object there is. Let's use it now" ], "tests":[ - "assert(1==2, '');" + "assert.deepEqual(array, [4,5,6,7,8], 'You should have added three to each value in the array');", + "assert(editor.getValue().match(/\\.map\\(/gi), 'You should be making use of the map method');", + "assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\]/gi), 'You should only modify the array with .map');" ], "challengeSeed":[ - "Under Construction" + "//Use map to add three to each value in the array", + "var array = [1,2,3,4,5];", + "", + "", + "", + "(function(){return(array);})();" ], "challengeType":1 }, @@ -195,13 +178,25 @@ "title":"Waypoint: Using .reduce", "difficulty":0, "description":[ - "" + "", + "Reduce can be useful for condensing and array or numbers into one value.", + "", + "var singleVal = array.reduce(function(previousVal, currentVal){", + " return(previousVal+currentVal);", + "}" ], "tests":[ - "assert(1==2, '');" + "assert(singleVal == 30, 'singleVal should have been set to the result of you reduce operation');", + "assert(editor.getValue().match(/\\.reduce\\(/gi), 'You should have made use of the reduce method');" ], "challengeSeed":[ - "Under Construction" + "var array = [4,5,6,7,8];", + "", + "var singleVal = 0;", + "", + "", + "", + "(function(){return(singleVal);})()" ], "challengeType":1 }, @@ -210,13 +205,24 @@ "title":"Waypoint: Using .filter", "difficulty":0, "description":[ - "" + "", + "filter is a useful method that can filter out values that don't match a certain criteria", + "Let's remove all the values less than six", + "array = array.filter(function(val){", + " return(val<4);", + "});" ], "tests":[ - "assert(1==2, '');" + "assert.deepEqual(array, [1,2,3,4,5], 'You should have removed all the values from the array that are less than six');", + "assert(editor.getValue().match(/array\\.filter\\(/gi), 'You should be using the filter method to remove the values from the array');", + "assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\,6\\,7\\,8\\,9\\,10\\]/gi), 'You should only be using .filter to modify the contents of the array);" ], "challengeSeed":[ - "Under Construction" + "var array = [1,2,3,4,5,6,7,8,9,10];", + "", + "", + "", + "(function(){return(array);})();" ], "challengeType":1 }, @@ -225,13 +231,24 @@ "title":"Waypoint: Using .sort", "difficulty":0, "description":[ + "", + "You can use the method sort to easily sort the values in the array alphabetically or numerically", + "var array = [1,3,2];", + "array = array.sort();", + "This will return [1, 2, 3]", "" ], "tests":[ - "assert(1==2, '');" + "assert.deepEqual(array, ['alpha', 'beta', 'charlie'], 'You should have sorted the array alphabetically');", + "assert(editor.getValue().match(/\\[\\'beta\\'\\,\\s\\'alpha\\'\\,\\s'charlie\\'\\];/gi), 'You should be sorting the array using sort');", + "assert(editor.getValue().match(/\\.sort\\(\\)/gi), 'You should have made use of the sort method');" ], "challengeSeed":[ - "Under Construction" + "var array = ['beta', 'alpha', 'charlie'];", + "", + "", + "", + "(function(){return(array);})();" ], "challengeType":1 }, @@ -240,13 +257,20 @@ "title": "Waypoint: Using .reverse", "difficulty": 0, "description": [ - "" + "", + "You can use the reverse method to reverse the contents of an array" ], "tests": [ - "assert(1==2, '');" + "assert.deepEqual(array, [7,6,5,4,3,2,1], 'You should reverse the array');", + "assert(editor.getValue().match(/\\.reverse\\(\\)/gi), '');", + "assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\,6\\,7/gi), '');" ], "challengeSeed": [ - "Under Construction" + "var array = [1,2,3,4,5,6,7];", + "", + "", + "", + "(function(){return(array);})();" ], "challengeType": 1 }, @@ -255,15 +279,70 @@ "title": "Waypoint: Using .concat", "difficulty": 0, "description": [ - "" + "", + "Concat can be used to merge the contents of two arrays into one", + "array = array.concat(otherArray);" ], "tests": [ - "assert(1==2, '');" + "assert.deepEqual(array, [1,2,3,4,5,6], 'You should concat the two arrays together');", + "assert(editor.getValue().match(/\\.concat\\(/gi), 'You should be using the concat method to merge the two arrays');", + "assert(editor.getValue().match(/\\[1\\,2\\,3\\]/gi) && editor.getValue().match(/\\[4\\,5\\,6\\]/gi), 'You should only modify the two arrays without changing the origional ones');" ], "challengeSeed": [ - "Under Construction" + "var array = [1,2,3];", + "", + "var concatMe = [4,5,6];", + "", + "", + "", + "(function(){return(array);})()" ], "challengeType": 1 + }, + { + "id":"cf1111c1c16feddfaeb4bdef", + "title":"Waypoint: Using .split", + "difficulty":0, + "description":[ + "", + "You can use the split method to split a string into an array", + "split uses the argument you give to to split the string", + "array = string.split(' ');" + ], + "tests":[ + "assert(typeof(array) === 'object' && array.length === 5, 'You should have split the string by it\\'s spaces');", + "assert(/\\.split\\(/gi, 'You should have made use of the split method on the string');" + ], + "challengeSeed":[ + "var string = \"Split me into an array\";", + "", + "var array = string;", + "", + "(function(){return(array);})();" + ], + "challengeType":1 + }, + { + "id":"cf1111c1c16feddfaeb5bdef", + "title":"Waypoint: Using .join", + "difficulty":0, + "description":[ + "", + "We can use the join method to join each element in an array into a string separated by whatever delimiter you provide as an argument to the join operation", + "var joinMe = joinMe.join(\" \");" + ], + "tests":[ + "assert(typeof(joinMe) === 'string' && joinMe === \"Split me into an array\", 'You should have joined the arrays by it\\'s spaces');", + "assert(/\\.join\\(/gi, 'You should have made use of the join method on the array');" + ], + "challengeSeed":[ + "var joinMe = [\"Split\",\"me\",\"into\",\"an\",\"array\"];", + "", + "joinMe = joinMe;", + "", + "(function(){return(joinMe);})();" + ], + "challengeType":1 } ] }