improvements to javascript challenges

This commit is contained in:
Quincy Larson
2015-08-16 04:05:15 -07:00
parent 1fbb2a32f8
commit bce3b34f9b
2 changed files with 143 additions and 121 deletions

View File

@ -1059,7 +1059,8 @@
"description":[ "description":[
"We can also use selectors like <code>\\s</code> to find spaces in a string.", "We can also use selectors like <code>\\s</code> to find spaces in a string.",
"It is used like this:", "It is used like this:",
"<code>/\\s+/g</code>" "<code>/\\s+/g</code>",
"Select all the spaces in the sentence string."
], ],
"tests":[ "tests":[
"assert(test === 7, 'Your RegEx should have found seven spaces in the <code>testString</code>.');", "assert(test === 7, 'Your RegEx should have found seven spaces in the <code>testString</code>.');",
@ -1067,15 +1068,15 @@
], ],
"challengeSeed":[ "challengeSeed":[
"var test = (function(){", "var test = (function(){",
" var testString = \"How many spaces are there in this sentence.\";", " var testString = \"How many spaces are there in this sentence?\";",
"", "",
" // Only change code below this line.", " // Only change code below this line.",
"", "",
" var expression = /.+/gi;", " var expression = /.+/gi;",
"", "",
"// Only change code above this line.", " // Only change code above this line.",
"// We use this function to show you the value of your variable in your output box.", " // We use this function to show you the value of your variable in your output box.",
" return(testString.match(expression).length);", " return(testString.match(expression).length);",
"})();(function(){return(test);})();" "})();(function(){return(test);})();"
], ],
"type": "waypoint", "type": "waypoint",
@ -1095,15 +1096,15 @@
], ],
"challengeSeed":[ "challengeSeed":[
"var test = (function(){", "var test = (function(){",
" var testString = \"How many spaces are there in this sentence.\";", " var testString = \"How many spaces are there in this sentence?\";",
"", "",
" // Only change code below this line.", " // Only change code below this line.",
"", "",
" var expression = /.+/gi;", " var expression = /./gi;",
"", "",
"// Only change code above this line.", " // Only change code above this line.",
"// We use this function to show you the value of your variable in your output box.", " // We use this function to show you the value of your variable in your output box.",
" return(testString.match(expression).length);", " return(testString.match(expression).length);",
"})();(function(){return(test);})();" "})();(function(){return(test);})();"
], ],
"type": "waypoint", "type": "waypoint",
@ -1115,16 +1116,16 @@
"difficulty":"9.988", "difficulty":"9.988",
"description":[ "description":[
"We are now going to try and combine some of the stuff we've just learned and create the logic for a slot machine game.", "We are now going to try and combine some of the stuff we've just learned and create the logic for a slot machine game.",
"For this we will need to generate three random numbers between <code>1</code> and <code>5</code> to represent the possible values of each individual slot.", "For this we will need to generate three random numbers between <code>1</code> and <code>3</code> to represent the possible values of each individual slot.",
"Store the three random numbers in <code>slotOne</code>, <code>slotTwo</code> and <code>slotThree</code>.", "Store the three random numbers in <code>slotOne</code>, <code>slotTwo</code> and <code>slotThree</code>.",
"Generate the random numbers by using the system we used earlier:", "Generate the random numbers by using the system we used earlier:",
"<code>Math.floor(Math.random() * (5 - 1 + 1)) + 1;</code>" "<code>Math.floor(Math.random() * (3 - 1 + 1)) + 1;</code>"
], ],
"tests":[ "tests":[
"assert(typeof(runSlots($(\".slot\"))[0]) === \"number\", '<code>slotOne</code> should be a random number.');", "assert(typeof(runSlots($(\".slot\"))[0]) === \"number\", '<code>slotOne</code> should be a random number.')",
"assert(typeof(runSlots($(\".slot\"))[1]) === \"number\", '<code>slotTwo</code> should be a random number.');", "assert(typeof(runSlots($(\".slot\"))[1]) === \"number\", '<code>slotTwo</code> should be a random number.')",
"assert(typeof(runSlots($(\".slot\"))[2]) === \"number\", '<code>slotThree</code> should be a random number.');", "assert(typeof(runSlots($(\".slot\"))[2]) === \"number\", '<code>slotThree</code> should be a random number.')",
"assert((function(){if(editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?5\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi) !== null){return(editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?5\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi).length >= 3);}else{return(false);}})(), 'You should have used <code>Math.floor(Math.random() * (5 - 1 + 1)) + 1;</code> three times to generate your random numbers.');" "assert((function(){if(editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?3\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi) !== null){return(editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?3\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi).length >= 3);}else{return(false);}})(), 'You should have used <code>Math.floor(Math.random() * (3 - 1 + 1)) + 1;</code> three times to generate your random numbers.')"
], ],
"challengeSeed":[ "challengeSeed":[
"fccss", "fccss",
@ -1133,7 +1134,7 @@
" var slotTwo;", " var slotTwo;",
" var slotThree;", " var slotThree;",
" ", " ",
" var images = [\"http://i.imgur.com/9H17QFk.png\", \"http://i.imgur.com/9RmpXTy.png\", \"http://i.imgur.com/VJnmtt5.png\", \"http://i.imgur.com/XK735i8.png\", \"http://i.imgur.com/Vt32Bf7.png\"];", " var images = [\"http://i.imgur.com/9H17QFk.png\", \"http://i.imgur.com/9RmpXTy.png\", \"http://i.imgur.com/VJnmtt5.png\"];",
" ", " ",
" // Only change code below this line.", " // Only change code below this line.",
" ", " ",
@ -1268,16 +1269,17 @@
"title": "Add your JavaScript Slot Machine Slots", "title": "Add your JavaScript Slot Machine Slots",
"difficulty":"9.989", "difficulty":"9.989",
"description":[ "description":[
"Now that we have our random numbers we need to go and check for when they are all the same that means we should count it as a win.", "Now that our slots will each generate random numbers, we need to check whether they've all returned the same number.",
"Different numbers will have different values so we need to return the matched number or null.", "If they have, we should notify our user that they've won.",
"If we get a match we should change the value of win to the number that we have three of or leave it as null.", "Otherwise, we should return <code>null</code>, which is a JavaScript data structure that means nothing.",
"Let's create an if statement with multiple conditions to check that all the numbers are equal.", "If all three numbers match, we should change the value of win to the number that we have three of or leave it as null.",
"Let's create an <code>if statement</code> with multiple conditions in order to check whether all numbers are equal.",
"<code>if(slotOne !== slotTwo || slotTwo !== slotThree){</code>", "<code>if(slotOne !== slotTwo || slotTwo !== slotThree){</code>",
"<code> return(null);</code>", "<code>&thinsp;&thinsp;return(null);</code>",
"<code>}</code>" "<code>}</code>"
], ],
"tests":[ "tests":[
"assert((function(){var data = runSlots();if(data === null){return(true)}else{if(data[0] === data[1] && data[1] === data[2]){return(true);}else{return(false);}}})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return null.');" "assert((function(){var data = runSlots();if(data === null){return(true)}else{if(data[0] === data[1] && data[1] === data[2]){return(true);}else{return(false);}}})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return null.')"
], ],
"challengeSeed":[ "challengeSeed":[
"fccss", "fccss",
@ -1286,11 +1288,11 @@
" var slotTwo;", " var slotTwo;",
" var slotThree;", " var slotThree;",
" ", " ",
" var images = [\"http://i.imgur.com/9H17QFk.png\", \"http://i.imgur.com/9RmpXTy.png\", \"http://i.imgur.com/VJnmtt5.png\", \"http://i.imgur.com/XK735i8.png\", \"http://i.imgur.com/Vt32Bf7.png\"];", " var images = [\"http://i.imgur.com/9H17QFk.png\", \"http://i.imgur.com/9RmpXTy.png\", \"http://i.imgur.com/VJnmtt5.png\"];",
" ", " ",
" slotOne = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotOne = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
" slotTwo = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
" slotThree = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
" ", " ",
" $(\".logger\").html(\"\");", " $(\".logger\").html(\"\");",
" $(\".logger\").html(\"Not A Win\")", " $(\".logger\").html(\"Not A Win\")",
@ -1428,15 +1430,15 @@
"difficulty":"9.990", "difficulty":"9.990",
"description":[ "description":[
"Now we can detect a win. Let's get this slot machine working.", "Now we can detect a win. Let's get this slot machine working.",
"We're going to use the jQuery selector <code>$(\".slot\")</code> to select all of the slots.", "Let's use the jQuery <code>selector</code> <code>$(\".slot\")</code> to select all of the slots.",
"Once they are all selected we can use bracket notation to access each individual one like this.", "Once they are all selected, we can use <code>bracket notation</code> to access each individual slot:",
"<code>$($(\".slot\")[0]).html(\"\")</code>", "<code>$($(\".slot\")[0]).html(slotOne);</code>",
"This will grab the the first slot so that we can add the numbers we generate to them.", "This jQuery will select the first and update the slot's HTML to display the correct number.",
"Use the above selector to display each number in the corresponding slot." "Use the above selector to display each number in its corresponding slot."
], ],
"tests":[ "tests":[
"assert((function(){runSlots();if($($(\".slot\")[0]).html().replace(/\\s/gi, \"\") !== \"\" && $($(\".slot\")[1]).html().replace(/\\s/gi, \"\") !== \"\" && $($(\".slot\")[2]).html().replace(/\\s/gi, \"\") !== \"\"){return(true);}else{return(false);}})(), 'You should be displaying the result of the slot numbers in the corresponding slots');", "assert((function(){runSlots();if($($(\".slot\")[0]).html().replace(/\\s/gi, \"\") !== \"\" && $($(\".slot\")[1]).html().replace(/\\s/gi, \"\") !== \"\" && $($(\".slot\")[2]).html().replace(/\\s/gi, \"\") !== \"\"){return(true);}else{return(false);}})(), 'You should be displaying the result of the slot numbers in the corresponding slots')",
"assert((function(){if(editor.match( /\\$\\(\\$\\(\\\"\\.slot\\\"\\)\\[\\d\\]\\)/gi )){if(editor.match( /\\$\\(\\$\\(\\\"\\.slot\\\"\\)\\[\\d\\]\\)/gi ).length >= 3 && editor.match( /\\.html\\(slotOne\\);/gi ) && editor.match( /\\.html\\(slotTwo\\);/gi ) && editor.match( /\\.html\\(slotThree\\);/gi )){return(true);}else{return(false);}}else{return(false);}})(), 'You should have used the the selector given in the description to select each slot and assign it the value of slotOne&#44; slotTwo and slotThree respectively');" "assert((function(){if(editor.match( /\\$\\(\\$\\(\\\"\\.slot\\\"\\)\\[\\d\\]\\)/gi )){if(editor.match( /\\$\\(\\$\\(\\\"\\.slot\\\"\\)\\[\\d\\]\\)/gi ).length >= 3 && editor.match( /\\.html\\(slotOne\\)/gi ) && editor.match( /\\.html\\(slotTwo\\)/gi ) && editor.match( /\\.html\\(slotThree\\)/gi )){return(true);}else{return(false);}}else{return(false);}})(), 'You should have used the the selector given in the description to select each slot and assign it the value of slotOne&#44; slotTwo and slotThree respectively')"
], ],
"challengeSeed":[ "challengeSeed":[
"fccss", "fccss",
@ -1445,11 +1447,11 @@
" var slotTwo;", " var slotTwo;",
" var slotThree;", " var slotThree;",
" ", " ",
" var images = [\"http://i.imgur.com/9H17QFk.png\", \"http://i.imgur.com/9RmpXTy.png\", \"http://i.imgur.com/VJnmtt5.png\", \"http://i.imgur.com/XK735i8.png\", \"http://i.imgur.com/Vt32Bf7.png\"];", " var images = [\"http://i.imgur.com/9H17QFk.png\", \"http://i.imgur.com/9RmpXTy.png\", \"http://i.imgur.com/VJnmtt5.png\"];",
" ", " ",
" slotOne = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotOne = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
" slotTwo = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
" slotThree = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
" ", " ",
" $(\".logger\").html(\"\");", " $(\".logger\").html(\"\");",
" $(\".logger\").html(\"Not A Win\")", " $(\".logger\").html(\"Not A Win\")",
@ -1593,14 +1595,17 @@
"title": "Give your JavaScript Slot Machine some stylish images", "title": "Give your JavaScript Slot Machine some stylish images",
"difficulty":"9.9901", "difficulty":"9.9901",
"description":[ "description":[
"Now that we can detect when the player wins we are going to add an image to each slot depending on the random values we generate:", "Now let's add some images to our slots.",
"<code>$($('.slot')[0]).html('&lt;img src = \"' + images[slotOne-1] + '\"&gt;');</code>" "We've already set up the images for you in an array called <code>images</code>. We can use different indexes to grab each of these.",
"Here's how we would set the first slot to show a different image depending on which number its random number generates:",
"<code>$($('.slot')[0]).html('&lt;img src = \"' + images[slotOne-1] + '\"&gt;');</code>",
"Set up all three slots like this, then click the \"Go\" button to play the slot machine."
], ],
"tests":[ "tests":[
"assert(editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi) && editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi).length >= 3, 'Use the provided code three times. One for each slot');", "assert(editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi) && editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi).length >= 3, 'Use the provided code three times. One for each slot')",
"assert(editor.match(/slotOne/gi) && editor.match(/slotOne/gi).length >= 7, 'You should have used the slotOne value at least once');", "assert(editor.match(/slotOne/gi) && editor.match(/slotOne/gi).length >= 7, 'You should have used the slotOne value at least once')",
"assert(editor.match(/slotTwo/gi) && editor.match(/slotTwo/gi).length >=8, 'You should have used the slotTwo value at least once');", "assert(editor.match(/slotTwo/gi) && editor.match(/slotTwo/gi).length >= 8, 'You should have used the slotTwo value at least once')",
"assert(editor.match(/slotThree/gi) && editor.match(/slotThree/gi).length >= 7, 'You should have used the slotThree value at least once');" "assert(editor.match(/slotThree/gi) && editor.match(/slotThree/gi).length >= 7, 'You should have used the slotThree value at least once')"
], ],
"challengeSeed":[ "challengeSeed":[
"fccss", "fccss",
@ -1609,11 +1614,11 @@
" var slotTwo;", " var slotTwo;",
" var slotThree;", " var slotThree;",
" ", " ",
" var images = [\"http://i.imgur.com/9H17QFk.png\", \"http://i.imgur.com/9RmpXTy.png\", \"http://i.imgur.com/VJnmtt5.png\", \"http://i.imgur.com/XK735i8.png\", \"http://i.imgur.com/Vt32Bf7.png\"];", " var images = [\"http://i.imgur.com/9H17QFk.png\", \"http://i.imgur.com/9RmpXTy.png\", \"http://i.imgur.com/VJnmtt5.png\"];",
" ", " ",
" slotOne = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotOne = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
" slotTwo = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
" slotThree = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
" ", " ",
" $('.logger').html('');", " $('.logger').html('');",
" $('.logger').html('Not A Win');", " $('.logger').html('Not A Win');",

View File

@ -2,84 +2,93 @@
"name": "Object Oriented and Functional Programming", "name": "Object Oriented and Functional Programming",
"order": 0.010, "order": 0.010,
"note": [ "note": [
"Waypoint: Closures", "Closures",
"Waypoint: Factories", "Factories",
"Waypoint: Pure Functions", "Pure Functions",
"Waypoint: Currying Functions", "Currying Functions",
"Waypoint: Functors", "Functors",
"Waypoint: Currying Functions" "Currying Functions"
], ],
"challenges": [ "challenges": [
{ {
"id":"cf1111c1c15feddfaeb1bdef", "id":"cf1111c1c15feddfaeb1bdef",
"title":"Waypoint: A Review On Objects", "title": "Declaring JavaScript Objects as Variables",
"difficulty":0, "difficulty":0,
"description":[ "description":[
"Before we dive into Object Oriented Programming, let's revisit JavaScript objects.", "Before we dive into Object Oriented Programming, let's revisit JavaScript objects.",
"Give your <code>motorBike</code> object the correct attributes." "Give your <code>motorBike</code> object a <code>wheels</code>, <code>engine</code> and <code>seats</code> attribute and set them to numbers."
], ],
"tests":[ "tests":[
"assert(motorBike.wheels===2, 'You should have given motorBike two wheels');", "assert(typeof(motorBike.engines) === 'number', '<code>engines</code> should be have a <code>engines</code> attribute set to a number.');",
"assert(motorBike.engine===1, 'You should have given motorBike one engine');", "assert(typeof(motorBike.wheels) === 'number', '<code>wheels</code> should be have a <code>engines</code> attribute set to a number.');",
"assert(motorBike.seats===1, 'You should have given motorBike one seat');" "assert(typeof(motorBike.seats) === 'number', '<code>seats</code> should be have a <code>engines</code> attribute set to a number.');"
], ],
"challengeSeed":[ "challengeSeed":[
"//Here is a sample Object", "//Here is a sample Object",
"var car = {", "var car = {",
" \"wheels\":4,", " \"wheels\":4,",
" \"engine\":1,", " \"engines\":1,",
" \"seats\":5", " \"seats\":5",
"};", "};",
"", "",
"//Now Let's make a similar Object called motorBike", "//Now Let's make a similar Object called motorBike",
"//Give it two wheels, one engine and one seat", "//Give it two wheels, one engine and one seat",
"var motorBike = {", "var motorBike = {",
" \"wheels\":0,", " // Only change code below this line.",
" \"engine\":0,", "",
" \"seats\":0", "",
"",
" // Only change code above this line.",
"};", "};",
"", "",
"(function(){return(JSON.stringify(motorBike));})();" "(function(){return(JSON.stringify(motorBike));})();"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint",
"type": "waypoint"
}, },
{ {
"id":"cf1111c1c15feddfaeb2bdef", "id":"cf1111c1c15feddfaeb2bdef",
"title":"Waypoint: Constructing Objects", "title": "Constructing JavaScript Objects with Functions",
"difficulty":0, "difficulty":0,
"description":[ "description":[
"We are also able to create objects using functions.", "We are also able to create objects using <code>constructor</code> functions.",
"" "Give your <code>motorBike</code> object a <code>wheels</code>, <code>engine</code> and <code>seats</code> attribute and set them to numbers."
], ],
"tests":[ "tests":[
"assert((new Car()).wheels === 4, \"myCar.wheels should be four. Make sure that you haven't changed this value\");", "assert(typeof((new Car()).engines) === 'number', '<code>engines</code> should be have a <code>engines</code> attribute set to a number.');",
"assert(typeof((new Car()).engine) === 'number', 'myCar.engine should be a number');", "assert(typeof((new Car()).wheels) === 'number', '<code>wheels</code> should be have a <code>engines</code> attribute set to a number.');",
"assert(typeof((new Car()).seats) === 'number', 'myCar.seats should be a number');" "assert(typeof((new Car()).seats) === 'number', '<code>seats</code> should be have a <code>engines</code> attribute set to a number.');"
], ],
"challengeSeed":[ "challengeSeed":[
"// Let's add the properties engine and seats to the car in the same way that the property wheels has been added below. They should both be numbers.", "// Let's add the properties engine and seats to the car in the same way that the property wheels has been added below. They should both be numbers.",
"var Car = function(){", "var Car = function(){",
" this.wheels = 4;", " // Only change code below this line.",
" this.wheels = 4;",
" this.engines = 1;",
" this.seats = 1;",
"};", "};",
"", "",
"var myCar = new Car();", "var motorBike = new Car();",
"// Only change code above this line.",
"", "",
"(function(){return(JSON.stringify(myCar));})();" "(function(){return(JSON.stringify(myCar));})();"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint"
}, },
{ {
"id":"cf1111c1c15feddfaeb3bdef", "id":"cf1111c1c15feddfaeb3bdef",
"title":"Waypoint: Understanding Public and Private Properties", "title":"Understanding Public and Private Properties",
"difficulty":0, "difficulty":0,
"description":[ "description":[
"In the last challenge we use the <code>this</code> to reference public properties the current object or function.", "In the last challenge we use the <code>this</code> to reference public properties the current object or function.",
"We can also create variables and functions that aren't accessible from outside the Object" "We can also create variables and functions that aren't accessible from outside the object."
], ],
"tests":[ "tests":[
"assert(typeof(myBike.getSpeed)!=='undefined' && typeof(myBike.getSpeed) === 'function', 'The method getSpeed of myBike should be accessible outside the Object');", "assert(typeof(myBike.getSpeed)!=='undefined' && typeof(myBike.getSpeed) === 'function', 'The method getSpeed of myBike should be accessible outside the object');",
"assert(typeof(myBike.speed) === 'undefined', 'We should not been able');", "assert(typeof(myBike.speed) === 'undefined', '<code>myBike.speed</code> should remain undefined.');",
"assert(typeof(myBike.addUnit === 'undefined'), '');" "assert(typeof(myBike.addUnit === 'undefined'), '<code>myBike.addUnit</code> should remain undefined.');"
], ],
"challengeSeed":[ "challengeSeed":[
"//Let's create an object with a two functions. One attached as a property and one not.", "//Let's create an object with a two functions. One attached as a property and one not.",
@ -113,15 +122,16 @@
"", "",
"if(myBike.hasOwnProperty('getSpeed')){(function(){return(JSON.stringify(myBike.getSpeed()));})();};" "if(myBike.hasOwnProperty('getSpeed')){(function(){return(JSON.stringify(myBike.getSpeed()));})();};"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint"
}, },
{ {
"id":"cf1111c1c15feddfaeb4bdef", "id":"cf1111c1c15feddfaeb4bdef",
"title":"Waypoint: Instantiation", "title":"Instantiation",
"difficulty":0, "difficulty":0,
"description":[ "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" "The instance inherits all the properties and methods of the original Object."
], ],
"tests":[ "tests":[
"assert((new Car()).wheels === 4, 'The property wheels should be four in the object constructor');", "assert((new Car()).wheels === 4, 'The property wheels should be four in the object constructor');",
@ -141,18 +151,19 @@
"", "",
"(function(){return(JSON.stringify(myCar));})();" "(function(){return(JSON.stringify(myCar));})();"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint"
}, },
{ {
"id":"cf1111c1c15feddfaeb7bdef", "id":"cf1111c1c15feddfaeb7bdef",
"title":"Waypoint: Using .map", "title":"Using .map",
"difficulty":0, "difficulty":0,
"description":[ "description":[
"<code>array = array.map(function(val){", "<code>array = array.map(function(val){</code>",
" return(val+1);", "<code>thinsp;thinsp;return(val+1);</code>",
"});</code>", "<code>});</code>",
"", "",
"The map method is one of the easiest ways to iterate through an array or object there is. Let's use it now" "The map method is one of the easiest ways to iterate through an array or object there is. Let's use it now."
], ],
"tests":[ "tests":[
"assert.deepEqual(array, [4,5,6,7,8], 'You should have added three to each value in the array');", "assert.deepEqual(array, [4,5,6,7,8], 'You should have added three to each value in the array');",
@ -167,17 +178,18 @@
"", "",
"(function(){return(array);})();" "(function(){return(array);})();"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint"
}, },
{ {
"id":"cf1111c1c15feddfaeb8bdef", "id":"cf1111c1c15feddfaeb8bdef",
"title":"Waypoint: Using .reduce", "title":"Using .reduce",
"difficulty":0, "difficulty":0,
"description":[ "description":[
"Reduce can be useful for condensing and array or numbers into one value.", "Reduce can be useful for condensing and array or numbers into one value.",
"<code>var singleVal = array.reduce(function(previousVal, currentVal){", "<code>var singleVal = array.reduce(function(previousVal, currentVal){</code>",
" return(previousVal+currentVal);", "<code>thinsp;thinsp;return(previousVal+currentVal);</code>",
"}</code>" "<code>}</code>"
], ],
"tests":[ "tests":[
"assert(singleVal == 30, 'singleVal should have been set to the result of you reduce operation');", "assert(singleVal == 30, 'singleVal should have been set to the result of you reduce operation');",
@ -191,19 +203,19 @@
"", "",
"(function(){return(singleVal);})()" "(function(){return(singleVal);})()"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint"
}, },
{ {
"id":"cf1111c1c15feddfaeb9bdef", "id":"cf1111c1c15feddfaeb9bdef",
"title":"Waypoint: Using .filter", "title":"Using .filter",
"difficulty":0, "difficulty":0,
"description":[ "description":[
"",
"filter is a useful method that can filter out values that don't match a certain criteria", "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", "Let's remove all the values less than six",
"<code>array = array.filter(function(val){", "<code>array = array.filter(function(val) {</code>",
" return(val<4);", "<code>thinsp;thinsp;return(val<4);</code>",
"});</code>" "<code>});</code>"
], ],
"tests":[ "tests":[
"assert.deepEqual(array, [1,2,3,4,5], 'You should have removed all the values from the array that are less than six');", "assert.deepEqual(array, [1,2,3,4,5], 'You should have removed all the values from the array that are less than six');",
@ -217,17 +229,18 @@
"", "",
"(function(){return(array);})();" "(function(){return(array);})();"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint"
}, },
{ {
"id":"cf1111c1c16feddfaeb1bdef", "id":"cf1111c1c16feddfaeb1bdef",
"title":"Waypoint: Using .sort", "title":"Using .sort",
"difficulty":0, "difficulty":0,
"description":[ "description":[
"You can use the method sort to easily sort the values in the array alphabetically or numerically", "You can use the method sort to easily sort the values in the array alphabetically or numerically",
"<code>var array = [1,3,2];", "<code>var array = [1,3,2];</code>",
"array = array.sort();</code>", "<code>array = array.sort();</code>",
"This will return [1, 2, 3]" "This will return <code>[1, 2, 3]</code>"
], ],
"tests":[ "tests":[
"assert.deepEqual(array, ['alpha', 'beta', 'charlie'], 'You should have sorted the array alphabetically');", "assert.deepEqual(array, ['alpha', 'beta', 'charlie'], 'You should have sorted the array alphabetically');",
@ -241,14 +254,15 @@
"", "",
"(function(){return(array);})();" "(function(){return(array);})();"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint"
}, },
{ {
"id": "cf1111c1c16feddfaeb2bdef", "id": "cf1111c1c16feddfaeb2bdef",
"title": "Waypoint: Using .reverse", "title": "Using .reverse",
"difficulty": 0, "difficulty": 0,
"description": [ "description": [
"You can use the reverse method to reverse the contents of an array" "You can use the <code>.reverse()</code> function to reverse the contents of an array."
], ],
"tests": [ "tests": [
"assert.deepEqual(array, [7,6,5,4,3,2,1], 'You should reverse the array');", "assert.deepEqual(array, [7,6,5,4,3,2,1], 'You should reverse the array');",
@ -262,14 +276,15 @@
"", "",
"(function(){return(array);})();" "(function(){return(array);})();"
], ],
"challengeType": 1 "challengeType": 1,
"type": "waypoint"
}, },
{ {
"id": "cf1111c1c16feddfaeb3bdef", "id": "cf1111c1c16feddfaeb3bdef",
"title": "Waypoint: Using .concat", "title": "Using .concat",
"difficulty": 0, "difficulty": 0,
"description": [ "description": [
"Concat can be used to merge the contents of two arrays into one", "<code>.concat()</code> can be used to merge the contents of two arrays into one.",
"<code>array = array.concat(otherArray);</code>" "<code>array = array.concat(otherArray);</code>"
], ],
"tests": [ "tests": [
@ -286,16 +301,16 @@
"", "",
"(function(){return(array);})()" "(function(){return(array);})()"
], ],
"challengeType": 1 "challengeType": 1,
"type": "waypoint"
}, },
{ {
"id":"cf1111c1c16feddfaeb4bdef", "id":"cf1111c1c16feddfaeb4bdef",
"title":"Waypoint: Using .split", "title":"Using .split",
"difficulty":0, "difficulty":0,
"description":[ "description":[
"", "You can use the <code>.split()</code> method to split a string into an array.",
"You can use the split method to split a string into an array", "split uses the argument you give to to split the string.",
"split uses the argument you give to to split the string",
"<code>array = string.split(' ');</code>" "<code>array = string.split(' ');</code>"
], ],
"tests":[ "tests":[
@ -309,14 +324,15 @@
"", "",
"(function(){return(array);})();" "(function(){return(array);})();"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint"
}, },
{ {
"id":"cf1111c1c16feddfaeb5bdef", "id":"cf1111c1c16feddfaeb5bdef",
"title":"Waypoint: Using .join", "title":"Using .join",
"difficulty":0, "difficulty":0,
"description":[ "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", "We can use the <code>.join()</code> method to join each element in an array into a string separated by whatever delimiter you provide as an argument to the join operation.",
"<code>var joinMe = joinMe.join(\" \");</code>" "<code>var joinMe = joinMe.join(\" \");</code>"
], ],
"tests":[ "tests":[
@ -330,7 +346,8 @@
"", "",
"(function(){return(joinMe);})();" "(function(){return(joinMe);})();"
], ],
"challengeType":1 "challengeType":1,
"type": "waypoint"
} }
] ]
} }