diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 97b37c6fab..1d291ec2de 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -4,26 +4,23 @@ "time": "3h", "challenges": [ { - "id":"bd7123c9c441eddfaeb4bdef", + "id": "bd7123c9c441eddfaeb4bdef", "title": "Comment your JavaScript Code", - "difficulty":"9.98", - "description":[ + "description": [ "Comments are lines of code that your computer will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what it does.", "Let's take a look at the two ways you can write comments in JavaScript.", "The double-slash comment will comment out the remainder of the text on the current line:", "// This is a comment.", "The slash-star-star-slash comment will comment out everything between the /* and the */ characters:", "/* This is also a comment */", - "Try creating one of each.", - "And one more thing you need to notice. Starting at this waypoint in JavaScript related challenges (except AngularJS, all Ziplines, Git, Node.js and Express.js, MongoDB and Full Stack JavaScript Projects) you can see contents of assert() functions (in some challenges except(), assert.equal() and so on) which are used to test your code. It's part of these challenges that you are able to see the tests that are running against your code." + "Try creating one of each." ], - "tests":[ - "assert(editor.getValue().match(/(\\/\\/)...../g), 'message: Create a // style comment that contains at least five letters');", + "tests": [ + "assert(editor.getValue().match(/(\\/\\/)...../g), 'message: Create a // style comment that contains at least five letters.');", "assert(editor.getValue().match(/(\\/\\*)[\\w\\W]{5,}(?=\\*\\/)/gm), 'message: Create a /* */ style comment that contains at least five letters.');", - "assert(editor.getValue().match(/(\\*\\/)/g), 'message: Make sure that you close the comment with a */');" - ], - "challengeSeed":[ + "assert(editor.getValue().match(/(\\*\\/)/g), 'message: Make sure that you close the comment with a */.');" ], + "challengeSeed": [], "type": "waypoint", "challengeType": 1 }, @@ -72,8 +69,6 @@ "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", "", "if(typeof(myName) !== \"undefined\"){(function(v){return v;})(myName);}" ], @@ -98,8 +93,7 @@ "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "if(typeof(myFirstName) !== \"undefined\" && typeof(myLastName) !== \"undefined\"){(function(){return myFirstName + ', ' + myLastName;})();}" ], "type": "waypoint", @@ -133,8 +127,7 @@ "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "if(typeof(lastNameLength) !== \"undefined\"){(function(){return lastNameLength;})();}" ], "type": "waypoint", @@ -167,8 +160,7 @@ "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(v){return v;})(firstLetterOfLastName);" ], "type": "waypoint", @@ -197,8 +189,7 @@ "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(v){return v;})(thirdLetterOfLastName);" ], "type": "waypoint", @@ -228,8 +219,7 @@ "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(v){return v;})(lastLetterOfLastName);" ], "type": "waypoint", @@ -259,8 +249,7 @@ "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(v){return v;})(secondToLastLetterOfLastName);" ], "type": "waypoint", @@ -272,17 +261,16 @@ "description": [ "Let's try to add two numbers using JavaScript.", "JavaScript uses the + symbol for addition.", - "Replace the 0 with the correct number so you can get the result mentioned in the comment." + "Change the 0 so that sum will equal 20." ], "tests": [ "assert((function(){if(sum === 20 && editor.getValue().match(/\\+/g).length >= 2){return true;}else{return false;}})(), 'message: Make the variable sum equal 20.');" ], "challengeSeed": [ - "var sum = 10 + 0; //make this equal to 20 by changing the 0 into the appropriate number.", + "var sum = 10 + 0;", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(z){return 'sum='+z;})(sum);" ], "type": "waypoint", @@ -294,17 +282,16 @@ "description": [ "We can also subtract one number from another.", "JavaScript uses the - symbol for subtraction.", - "Replace the 0 with the correct number so you can get the result mentioned in the comment." + "Change the 0 so that difference will equal 12." ], "tests": [ "assert((function(){if(difference === 12 && editor.getValue().match(/\\-/g)){return true;}else{return false;}})(), 'message: Make the variable difference equal 12.');" ], "challengeSeed": [ - "var difference = 45 - 0; //make this equal to 12 by changing the 0 into the appropriate number.", + "var difference = 45 - 0; //12", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(z){return 'difference='+z;})(difference);" ], "type": "waypoint", @@ -316,17 +303,16 @@ "description": [ "We can also multiply one number by another.", "JavaScript uses the * symbol for multiplication.", - "Replace the 0 with the correct number so you can get the result mentioned in the comment." + "Change the 0 so that product will equal 80." ], "tests": [ "assert((function(){if(product === 80 && editor.getValue().match(/\\*/g)){return true;}else{return false;}})(), 'message: Make the variable product equal 80.');" ], "challengeSeed": [ - "var product = 8 * 0; // Make this equal to 80 by changing the 0 into the appropriate number.", + "var product = 8 * 0;", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(z){return 'product='+z;})(product);" ], "type": "waypoint", @@ -338,17 +324,16 @@ "description": [ "We can also divide one number by another.", "JavaScript uses the / symbol for division.", - "Replace the 0 with the correct number so you can get the result mentioned in the comment." + "Change the 0 so that quotient will equal 2." ], "tests": [ "assert((function(){if(quotient === 2 && editor.getValue().match(/var\\s*?quotient\\s*?\\=\\s*?\\d+\\s*?\\/\\s*?\\d+\\s*?;/g)){return true;}else{return false;}})(), 'message: Make the variable quotient equal 2.');" ], "challengeSeed": [ - "var quotient = 66 / 0; //make this equal to 2 by changing the 0 into the appropriate number.", + "var quotient = 66 / 0;", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(z){return 'quotient='+z;})(quotient);" ], "type": "waypoint", @@ -365,14 +350,11 @@ "assert((function(){if(typeof(myDecimal) !== \"undefined\" && typeof(myDecimal) === \"number\" && editor.getValue().match(/\\./g).length >=2){return true;}else{return false;}})(), 'message: myDecimal should be a decimal point number.');" ], "challengeSeed": [ - "// var ourDecimal = 5.7;", - "// Create a number with a decimal point here called myDecimal", - "", + "var ourDecimal = 5.7;", "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(){if(typeof(myDecimal) !== \"undefined\"){return myDecimal;}})();" ], "type": "waypoint", @@ -380,28 +362,47 @@ }, { "id": "bd7993c9c69feddfaeb7bdef", - "title": "Perform Arithmetic Operations on Decimals with JavaScript", + "title": "Multiply Two Decimals with JavaScript", "description": [ "In JavaScript, you can also perform calculations with decimal numbers, just like whole numbers.", - "Replace the 0.0 with the correct number so that you get the result mentioned in the comments." + "Let's multiply two decimals together to get their product.", + "Change the 0.0 so that product will equal 5.0." ], "tests": [ - "assert((function(){if(product === 5.0 && editor.getValue().match(/\\*/g)){return true;}else{return false;}})(), 'message: Make the variable product equal 5.0.');", - "assert((function(){if(quotient === 2.2 && editor.getValue().match(/\\//g)){return true;}else{return false;}})(), 'message: Make the variable quotient equal 2.2.');" + "assert((function(){if(product === 5.0 && editor.getValue().match(/\\*/g)){return true;}else{return false;}})(), 'message: Make the variable product equal 5.0.');" ], "challengeSeed": [ - "var quotient = 4.4 / 2.0; // equals 2.2", - "var product = 2.0 * 0.0; // equals 5.0", + "var product = 2.0 * 0.0;", "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(y){return 'product='+y;})(product);" ], "type": "waypoint", "challengeType": 1 }, + { + "id": "bd7993c9ca9feddfaeb7bdef", + "title": "Divide one Decimal by Another with JavaScript", + "description": [ + "Now let's divide one decimal by another.", + "Change the 0.0 so that your quotient will equal 2.2." + ], + "tests": [ + "assert((function(){if(quotient === 2.2 && editor.getValue().match(/\\//g)){return true;}else{return false;}})(), 'message: Make the variable quotient equal 2.2.');" + ], + "challengeSeed": [ + "var quotient = 0.0 / 2.0; // equals 2.2", + "", + "", + "// Only change code above this line.", + "", + "(function(y){return 'quotient='+y;})(quotient);" + ], + "type": "waypoint", + "challengeType": 1 + }, { "id": "bd7993c9c69feddfaeb8bdef", "title": "Store Multiple Values in one Variable using JavaScript Arrays", @@ -424,43 +425,40 @@ "var myArray = [];", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(z){return z;})(myArray);" ], "type": "waypoint", "challengeType": 1 }, { - "id":"cf1111c1c11feddfaeb7bdef", + "id": "cf1111c1c11feddfaeb7bdef", "title": "Nest one Array within Another Array", - "difficulty":"9.98161", - "description":[ + "description": [ "You can also nest arrays within other arrays, like this: [[\"Bulls\", 23]].", "Let's now go create a nested array called myArray." ], - "tests":[ + "tests": [ "assert(Array.isArray(myArray) && myArray.some(Array.isArray), 'message: myArray should have at least one array nested within another array.');" ], - "challengeSeed":[ + "challengeSeed": [ "var ourArray = [[\"the universe\", \"everything\", 42]];", + "", "// Only change code below this line.", "", "var myArray = [];", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}" ], "type": "waypoint", "challengeType": 1 }, { - "id":"bg9997c9c79feddfaeb9bdef", + "id": "bg9997c9c79feddfaeb9bdef", "title": "Access Array Data with Indexes", - "difficulty":"9.9817", - "description":[ + "description": [ "We can access the data inside arrays using indexes.", "Array indexes are written in the same bracket notation that strings use, except that instead of specifying a character, they are specifying an entry in the array.", "For example:", @@ -469,51 +467,50 @@ "var data = array[1];", "Create a variable called myData and set it to equal the first value of myArray." ], - "tests":[ + "tests": [ "assert((function(){if(typeof(myArray) != 'undefined' && typeof(myData) != 'undefined' && myArray[0] == myData){return true;}else{return false;}})(), 'message: The variable myData should equal the first value of myArray.');" ], - "challengeSeed":[ + "challengeSeed": [ "// var ourArray = [1,2,3];", "// var ourData = ourArray[0]; // equals 1", "", "var myArray = [1,2,3];", + "", "// Only change code below this line.", "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "if(typeof(myArray) !== \"undefined\" && typeof(myData) !== \"undefined\"){(function(y,z){return 'myArray = ' + JSON.stringify(y) + ', myData = ' + JSON.stringify(z);})(myArray, myData);}" ], "type": "waypoint", "challengeType": 1 }, { - "id":"cf1111c1c11feddfaeb8bdef", + "id": "cf1111c1c11feddfaeb8bdef", "title": "Modify Array Data With Indexes", - "difficulty":"9.98171", - "description":[ + "description": [ "We can also modify the data stored in arrays by using indexes.", "For example:", "var ourArray = [3,2,1];", "ourArray[0] = 1; // equals [1,2,1]", "Now modify the data stored at index 0 of myArray to the value of 3." ], - "tests":[ + "tests": [ "assert((function(){if(typeof(myArray) != 'undefined' && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return true;}else{return false;}})(), 'message: myArray should now be [3,2,3].');", "assert((function(){if(editor.getValue().match(/myArray\\[0\\]\\s?=\\s?/g)){return true;}else{return false;}})(), 'message: You should be using correct index to modify the value in myArray.');" ], - "challengeSeed":[ + "challengeSeed": [ "var ourArray = [1,2,3];", - "ourArray[1] = 3;", - "// ourArray now equals [1,3,3].", + "ourArray[1] = 3; // ourArray now equals [1,3,3].", + "", "var myArray = [1,2,3];", + "", "// Only change code below this line.", "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}" ], "type": "waypoint", @@ -524,30 +521,27 @@ "title": "Manipulate Arrays With pop()", "description": [ "Another way to change the data in an array is with the .pop() function.", - ".pop()is used to \"pop\" a value off of the end of an array. We can retrieve this value by performing pop() in a variable declaration.", - "Any type of variable can be \"popped\" off of an array.", - "Use the .pop() function to remove the last item from myArray." + ".pop()is used to \"pop\" a value off of the end of an array. We can store this \"popped off\" variable by performing pop() within a variable declaration.", + "Any type of data structure can be \"popped\" off of an array - numbers, strings, even nested arrays.", + "Use the .pop() function to remove the last item from myArray, assigning the \"popped off\" value to removedFromMyArray." ], "tests": [ "assert((function(d){if(d[0] == 'John' && d[1] == 23 && d[2] == undefined){return true;}else{return false;}})(myArray), 'message: myArray should only contain [\"John\", 23].');", - "assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return true;}else{return false;}})(removed), 'message: removed should only contain [\"cat\", 2].');" + "assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return true;}else{return false;}})(removed), 'message: removedFromMyArray should only contain [\"cat\", 2].');" ], "challengeSeed": [ - "// var numbers = [1,2,3];", - "// console.log(numbers); // logs [1,2,3]", - "// var removed = numbers.pop();", - "// console.log(numbers); // logs [1,2]", - "// console.log(removed); // logs 3", + "var ourArray = [1,2,3];", + "var removedFromOurArray = numbers.pop(); // removedFromOurArray now equals 3, and ourArray now equals [1,2]", "", "var myArray = [\"John\", 23, [\"cat\", 2]];", + "", "// Only change code below this line.", "", - "var removed = myArray; // This should be [\"cat\", 2] and myArray should now be [\"John\", 23]", + "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", - "(function(y, z){return 'myArray = ' + JSON.stringify(y) + ' & removed = ' + JSON.stringify(z);})(myArray, removed);" + "", + "(function(y, z){return 'removedFromMyArray = ' + JSON.stringify(y) + ' & removed = ' + JSON.stringify(z);})(myArray, removedFromMyArray);" ], "type": "waypoint", "challengeType": 1 @@ -557,26 +551,28 @@ "title": "Manipulate Arrays With push()", "description": [ "Not only can you pop() data off of the end of an array, you can also push() data onto the end of an array.", - "Take the myArray array and push() this value to the end of it: [\"dog\", 3]." + "Push [\"dog\", 3] onto the end of the myArray variable." ], "tests": [ "assert((function(d){if(d[2] != undefined && d[0] == 'John' && d[1] == 23 && d[2][0] == 'dog' && d[2][1] == 3 && d[2].length == 2){return true;}else{return false;}})(myArray), 'message: myArray should now equal [\"John\", 23, [\"dog\", 3]].');" ], "challengeSeed": [ "var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];", - "ourArray.pop();", - "ourArray.push([\"happy\", \"joy\"]);", - "// ourArray now equals [\"Stimpson\", \"J\", [\"happy\", \"joy\"]].", + "", + "ourArray.pop(); // ourArray now equals [\"Stimpson\", \"J\"]", + "", + "ourArray.push([\"happy\", \"joy\"]); // ourArray now equals [\"Stimpson\", \"J\", [\"happy\", \"joy\"]]", "", "var myArray = [\"John\", 23, [\"cat\", 2]];", + "", "myArray.pop();", - "// Add a [\"dog\", 3] to the end of myArray using push().", + "", "// Only change code below this line.", "", "", + "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(z){return 'myArray = ' + JSON.stringify(z);})(myArray);" ], "type": "waypoint", @@ -586,28 +582,29 @@ "id": "bg9996c9c69feddfaeb9bdef", "title": "Manipulate Arrays With shift()", "description": [ - "pop() always removes the last element of an array. What if you want to remove the first? That's where .shift() comes in.", - "Take the myArray array and shift() the first value off of it. Set myRemoved to the first value of myArray using shift()." + "pop() always removes the last element of an array. What if you want to remove the first?", + "That's where .shift() comes in. It works just like .pop(), except it removes the first element instead of the last.", + "Use the .shift() function to remove the first item from myArray, assigning the \"shifted off\" value to removedFromMyArray." ], "tests": [ "assert((function(d){if(d[0] == 23 && d[1][0] == 'dog' && d[1][1] == 3 && d[2] == undefined){return true;}else{return false;}})(myArray), 'message: myArray should now equal [23, [\"dog\", 3]].');", - "assert((function(d){if(d === 'John' && typeof(myRemoved) === 'string'){return true;}else{return false;}})(myRemoved), 'message: myRemoved should contain \"John\".');" + "assert((function(d){if(d === 'John' && typeof(removedFromMyArray) === 'string'){return true;}else{return false;}})(removedFromMyArray), 'message: removedFromMyArray should contain \"John\".');" ], "challengeSeed": [ "var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];", - "ourRemoved = ourArray.shift();", - "// ourArray now equals [\"J\", [\"cat\"]].", + "", + "removedFromOurArray = ourArray.shift(); // removedFromOurArray now equals \"Stimpson\" and ourArray now equals [\"J\", [\"cat\"]].", "", "var myArray = [\"John\", 23, [\"dog\", 3]];", + "", "// Only change code below this line.", "", - "var myRemoved = myArray; // This should be [\"John\"] and myArray should now be [23, [\"dog\", 3]].", + "", "", "// Only change code above this line.", "", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", - "(function(y, z){return 'myArray = ' + JSON.stringify(y) + ' & myRemoved = ' + JSON.stringify(z);})(myArray, myRemoved);" + "", + "(function(y, z){return 'myArray = ' + JSON.stringify(y) + ' & removedFromMyArray = ' + JSON.stringify(z);})(myArray, removedFromMyArray);" ], "type": "waypoint", "challengeType": 1 @@ -616,39 +613,39 @@ "id": "bg9997c9c69feddfaeb9bdef", "title": "Manipulate Arrays With unshift()", "description": [ - "Now that we've learned how to shiftthings from the start of the array, we need to learn how to unshiftstuff back to the start.", - "Let's take the code we had last time and unshiftthis value to the start: \"Paul\"." + "Not only can you shift elements off of the beginning of an array, you can also unshift elements onto the beginning of an array.", + "unshift() works exactly like push(), but instead of adding the element at the end of the array, unshift() adds the element at the beginning of the array.", + "Add \"Paul\" onto the beginning of the myArray variable using unshift()." ], "tests": [ "assert((function(d){if(typeof(d[0]) === \"string\" && d[0].toLowerCase() == 'paul' && d[1] == 23 && d[2][0] != undefined && d[2][0] == 'dog' && d[2][1] != undefined && d[2][1] == 3){return true;}else{return false;}})(myArray), 'message: myArray should now have [\"Paul\", 23, [\"dog\", 3]]).');" ], "challengeSeed": [ "var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];", - "ourArray.shift();", - "// ourArray now equals [\"J\", [\"cat\"]]", - "ourArray.unshift(\"happy\");", - "// ourArray now equals [\"happy\", \"J\", [\"cat\"]]", + "", + "ourArray.shift(); // ourArray now equals [\"J\", [\"cat\"]]", + "", + "ourArray.unshift(\"happy\"); // ourArray now equals [\"happy\", \"J\", [\"cat\"]]", "", "var myArray = [\"John\", 23, [\"dog\", 3]];", + "", "myArray.shift();", "", - "// Add \"Paul\" to the start of myArray.", "// Only change code below this line.", "", "", + "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "(function(y, z){return 'myArray = ' + JSON.stringify(y);})(myArray);" ], "type": "waypoint", "challengeType": 1 }, { - "id":"bg9997c9c89feddfaeb9bdef", + "id": "bg9997c9c89feddfaeb9bdef", "title": "Write Reusable JavaScript with Functions", - "difficulty":"9.9819", - "description":[ + "description": [ "In JavaScript, we can divide up our code into reusable parts called functions.", "Here's an example of a function:", "function functionName(a, b) {", @@ -659,10 +656,10 @@ "In this example, the function will return the number 6 as this is the result of 4 + 2.", "Create and call a function called myFunction that returns the sum of a and b." ], - "tests":[ + "tests": [ "assert((function(){if(typeof(f) !== \"undefined\" && f === a + b){return true;}else{return false;}})(), 'message: Your function should return the value of a + b');" ], - "challengeSeed":[ + "challengeSeed": [ "var a = 4;", "var b = 5;", "", @@ -670,15 +667,13 @@ " return a - b;", "}", "", - "// Create a function called myFunction that returns the value of a plus b.", "// Only change code below this line.", "", "", "", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "if(typeof(myFunction) !== \"undefined\"){", "var f=myFunction(a,b);", "(function(){return f;})();", @@ -688,44 +683,44 @@ "challengeType": 1 }, { - "id":"bg9998c9c99feddfaeb9bdef", + "id": "bg9998c9c99feddfaeb9bdef", "title": "Build JavaScript Objects", - "difficulty":"9.9822", - "description":[ + "description": [ "You may have heard the term object before.", "Objects are similar to arrays, except that instead of using indexes to access and modify their data, you access the data in objects through what are called properties.", "Here's a sample object:", "var cat = {", - " \"name\": \"Whiskers\",", - " \"legs\": 4,", - " \"tails\": 1,", - " \"enemies\": [\"Water\", \"Dogs\"]", + "  \"name\": \"Whiskers\",", + "  \"legs\": 4,", + "  \"tails\": 1,", + "  \"enemies\": [\"Water\", \"Dogs\"]", "};", "", "Objects are useful for storing data in a structured way, and can represent real world objects, like a cat.", - "Let's try to make an object that represents a dog called myDog which contains the properties 'name' (String), 'legs' (Number), 'tails' (Number) and 'friends' (Array)!" + "Let's try to make an object that represents a dog called myDog which contains the properties \"name\" (a string), \"legs\", \"tails\" and \"friends\".", + "You can set these object properties to whatever values you want, as long \"name\" is a string, \"legs\" and \"tails\" are numbers, and \"friends\" is an array." ], - "tests":[ + "tests": [ "assert((function(z){if(z.hasOwnProperty(\"name\") && z.name !== undefined && typeof(z.name) === \"string\"){return true;}else{return false;}})(myDog), 'message: myDog should contain the property name and it should be a string.');", "assert((function(z){if(z.hasOwnProperty(\"legs\") && z.legs !== undefined && typeof(z.legs) === \"number\"){return true;}else{return false;}})(myDog), 'message: myDog should contain the property legs and it should be a number.');", "assert((function(z){if(z.hasOwnProperty(\"tails\") && z.tails !== undefined && typeof(z.tails) === \"number\"){return true;}else{return false;}})(myDog), 'message: myDog should contain the property tails and it should be a number.');", "assert((function(z){if(z.hasOwnProperty(\"friends\") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), 'message: myDog should contain the property friends and it should be an array.');" ], - "challengeSeed":[ - "// var ourDog = {", - "// \"name\": \"Camper\",", - "// \"legs\": 4,", - "// \"tails\": 1,", - "// \"friends\": [\"everything!\"]", - "// };", - "", - "// Add the name (string), legs (number), tails (number) and friends (array) properties to myDog.", - "// You can set them to whatever you want.", + "challengeSeed": [ + "var ourDog = {", + " \"name\": \"Camper\",", + " \"legs\": 4,", + " \"tails\": 1,", + " \"friends\": [\"everything!\"]", + "};", "", "// Only change code below this line.", "", "var myDog = {", - " ", + "", + "", + "", + "", "};", "", "// Only change code above this line.", @@ -736,42 +731,44 @@ "challengeType": 1 }, { - "id":"bg9999c9c99feddfaeb9bdef", - "title": "Manipulate JavaScript Objects", - "difficulty":"9.9823", - "description":[ - "There are many ways to add and remove properties from objects.", - "For example, we can add properties to objects like this:", - "myObject.myProperty = \"myValue\";", - "We can also delete them like this:", - "delete myObject.myProperty;", - "Let's add the property \"bark\", and delete the property \"tails\"." + "id": "bg9999c9c99feddfaeb9bdef", + "title": "Update the Properties of a JavaScript Object", + "description": [ + "After you've created a JavaScript object, you can update its properties at any time just like you would update any other variable.", + "For example, let's look at ourDog:", + "var ourDog = {", + " \"name\": \"Camper\",", + " \"legs\": 4,", + " \"tails\": 1,,", + " \"friends\": [\"everything!\"]", + "};", + "Since he's a particularly happy dog, let's change his name to \"Happy Camper\". Here's how we update his object's name property:", + "myDog.name = \"Happy Camper\";", + "Now when we run return myDog.name, instead of getting \"Camper\", we'll get his new name, \"Happy Camper\".", + "Let's update yourDog object's name property. Let's change her name from \"Coder\" to \"Happy Coder\"." ], - "tests":[ - "assert(myDog.bark !== undefined, 'message: Add the property \"bark\" to myDog.');", - "assert(myDog.tails === undefined, 'message: Delete the property \"tails\" from myDog.');" + "tests": [ + "assert(myDog.name.match(/Happy Coder/), 'message: Update myDog's \"name\" property to equal \"Happy Coder\".');" ], - "challengeSeed":[ - "// var ourDog = {", - "// \"name\": \"Camper\",", - "// \"legs\": 4,", - "// \"tails\": 1,", - "// \"friends\": [\"everything!\"]", - "// };", + "challengeSeed": [ + "var ourDog = {", + " \"name\": \"Camper\",", + " \"legs\": 4,", + " \"tails\": 1,", + " \"friends\": [\"everything!\"]", + "};", "", - "// ourDog.bark = \"arf!\";", - "// delete ourDog.tails;", + "ourDog.name = \"Happy Camper\";", "", "var myDog = {", - " \"name\": \"Camper\",", - " \"legs\": 4,", - " \"tails\": 1,", - " \"friends\": []", + " \"name\": \"Coder\",", + " \"legs\": 4,", + " \"tails\": 1,", + " \"friends\": [\"Free Code Camp Campers\"]", "};", "", "// Only change code below this line.", "", - "// Let's add the property bark to myDog", "", "", "// Now delete the property tails", @@ -785,10 +782,93 @@ "challengeType": 1 }, { - "id":"cf1111c1c11feddfaeb5bdef", + "id": "bg9999c9c99feedfaeb9bdef", + "title": "Add New Properties to a JavaScript Object", + "description": [ + "You can add new properties to existing JavaScript objects the same way you would modify them.", + "Here's how we would add a \"bark\" property to ourDog:", + "myDog.bark = \"bow-wow\";", + "Now when we run return myDog.bark, we'll get his bark, \"bow-wow\".", + "Let's add a \"bark\" property to myDog and set it to a dog sound, such as \"woof\"." + ], + "tests": [ + "assert(myDog.bark !== undefined, 'message: Add the property \"bark\" to myDog.');" + ], + "challengeSeed": [ + "var ourDog = {", + " \"name\": \"Camper\",", + " \"legs\": 4,", + " \"tails\": 1,", + " \"friends\": [\"everything!\"]", + "};", + "", + "ourDog.bark = \"bow-wow\";", + "", + "var myDog = {", + " \"name\": \"Happy Coder\",", + " \"legs\": 4,", + " \"tails\": 1,", + " \"friends\": [\"Free Code Camp Campers\"]", + "};", + "", + "// Only change code below this line.", + "", + "", + "", + "// Only change code above this line.", + "", + "// We use this function to show you the value of your variable in your output box.", + "(function(z){return z;})(myDog);" + ], + "type": "waypoint", + "challengeType": 1 + }, + { + "id": "bg9999c9c99fdddfaeb9bdef", + "title": "Delete Properties from a JavaScript Object", + "description": [ + "We can also delete properties from objects like this:", + "delete myDog.bark;", + "Let's delete the \"tails\" property from myDog." + ], + "tests": [ + "assert(myDog.bark === undefined, 'message: Delete the property \"bark\" from myDog.');" + ], + "challengeSeed": [ + "var ourDog = {", + " \"name\": \"Camper\",", + " \"legs\": 4,", + " \"tails\": 1,", + " \"friends\": [\"everything!\"]", + " \"bark\": \"bow-wow\"", + "};", + "", + "delete ourDog.bark;", + "", + "var myDog = {", + " \"name\": \"Happy Coder\",", + " \"legs\": 4,", + " \"tails\": 1,", + " \"friends\": [\"Free Code Camp Campers\"]", + " \"bark\": \"woof\"", + "};", + "", + "// Only change code below this line.", + "", + "", + "", + "// Only change code above this line.", + "", + "// We use this function to show you the value of your variable in your output box.", + "(function(z){return z;})(myDog);" + ], + "type": "waypoint", + "challengeType": 1 + }, + { + "id": "cf1111c1c11feddfaeb5bdef", "title": "Iterate with JavaScript For Loops", - "difficulty":"9.9824", - "description":[ + "description": [ "You can run the same code multiple times by using a loop.", "The most common type of JavaScript loop is called a \"for loop\" because it runs \"for\" a specific number of times.", "var ourArray = [];", @@ -798,11 +878,11 @@ "ourArray will now contain [0,1,2,3,4] ", "Let's try getting a for loop to work by pushing values to an array." ], - "tests":[ + "tests": [ "assert(editor.getValue().match(/for/g), 'message: You should be using a for loop for this.');", "assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray should equal [0,1,2,3,4].');" ], - "challengeSeed":[ + "challengeSeed": [ "var ourArray = [];", "for(var i = 0; i < 5; i++){", " ourArray.push(i);", @@ -811,11 +891,9 @@ "", "// Only change code below this line.", "", - "// Push the numbers zero through four to myArray using a \"for loop\" like above.", - "", + "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}", "" ], @@ -823,10 +901,9 @@ "challengeType": 1 }, { - "id":"cf1111c1c11feddfaeb1bdef", + "id": "cf1111c1c11feddfaeb1bdef", "title": "Iterate with JavaScript While Loops", - "difficulty":"9.9825", - "description":[ + "description": [ "You can run the same code multiple times by using a loop.", "Another type of JavaScript loop is called a \"while loop\", because it runs \"while\" something is true and stops once that something is no longer true.", "var ourArray = [];", @@ -837,19 +914,18 @@ "}", "Let's try getting a while loop to work by pushing values to an array." ], - "tests":[ + "tests": [ "assert(editor.getValue().match(/while/g), 'message: You should be using a while loop for this.');", "assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray should equal [0,1,2,3,4].');" ], - "challengeSeed":[ + "challengeSeed": [ "var myArray = [];", "// Only change code below this line.", "", "// Push the numbers zero through four to myArray using a \"while loop\".", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", - "// You'll learn about functions soon.", + "", "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}", "" ], @@ -857,22 +933,21 @@ "challengeType": 1 }, { - "id":"cf1111c1c11feddfaeb9bdef", + "id": "cf1111c1c11feddfaeb9bdef", "title": "Generate Random Fractions with JavaScript", - "difficulty":"9.9827", - "description":[ + "description": [ "Random numbers are useful for creating random behavior.", "JavaScript has a Math.random() function that generates a random decimal number.", - "Use Math.random() to get myFunction to return a random number." + "Change myFunction to return a random number instead of returning 0." + "Note that you can return a function, just like you would return a variable or value." ], - "tests":[ + "tests": [ "assert(typeof(myFunction()) === \"number\", 'message: myFunction should return a random number.');", "assert((myFunction()+''). match(/\\./g), 'message: The number returned by myFunction should be a decimal.');", "assert(editor.getValue().match(/Math\\.random/g).length >= 2, 'message: You should be using Math.random to generate the random decimal number.');" ], - "challengeSeed":[ + "challengeSeed": [ "function myFunction() {", - " // Change the 0 to Math.random().", " // Only change code below this line.", "", " return 0;", @@ -887,26 +962,30 @@ "challengeType": 1 }, { - "id":"cf1111c1c12feddfaeb1bdef", + "id": "cf1111c1c12feddfaeb1bdef", "title": "Generate Random Whole Numbers with JavaScript", - "difficulty":"9.9828", - "description":[ - "It's great that we can create random decimal numbers, but it's even more useful if we use it to generate a random whole number.", - "To achieve this we can multiply the random number by ten and use the Math.floor() to convert the decimal number to the nearest less than or equal whole number.", - "This technique gives us a whole number between zero and nine.", - "Example:", - "Math.floor(Math.random()*10);", - "Let's give this technique a go now." + "description": [ + "It's great that we can create random decimal numbers, but it's even more useful if we use it to generate random whole numbers.", + "First, let's use Math.random() to create a random decimal.", + "Then let's multiply this random decimal by 20.", + "Finally, let's use another function, Math.floor() to round the number down to its nearest whole number.", + "This technique will gives us a whole number between 0 and 19.", + "Note that because we're rounding down, it's impossible to actually get 20.", + "Putting everything together, this is what our code looks like:", + "Math.floor(Math.random() * 20);", + "See how Math.floor takes (Math.random() * 20) as its argument? That's right - you can pass a function to another function as an argument." + "Let's use this technique to create and return a random whole number between 0 and 9." ], - "tests":[ + "tests": [ "assert(typeof(myFunction()) === \"number\", 'message: The result of myFunction should be a number.');", "assert(editor.getValue().match(/Math.random/g), 'message: You should be using Math.random to create a random number.');", "assert(editor.getValue().match(/\\(\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\*\\s*?10\\s*?\\)/g) || editor.getValue().match(/\\(\\s*?10\\s*?\\*\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\)/g), 'message: You should have multiplied the result of Math.random by 10 to make it a number that is between zero and nine.');", "assert(editor.getValue().match(/Math.floor/g), 'message: You should use Math.floor to remove the decimal part of the number.');" ], - "challengeSeed":[ + "challengeSeed": [ + "var randomNumberBetween0and19 = Math.floor(Math.random() * 20);", + "", "function myFunction(){", - " // Make myFunction return a random number between zero and nine instead of a decimal.", "", " // Only change code below this line.", "", @@ -922,42 +1001,41 @@ "challengeType": 1 }, { - "id":"cf1111c1c12feddfaeb2bdef", + "id": "cf1111c1c12feddfaeb2bdef", "title": "Generate Random Whole Numbers within a Range", - "difficulty":"9.9829", - "description":[ + "description": [ "We can use a certain mathematical expression to get a random number between two numbers.", "Math.floor(Math.random() * (max - min + 1)) + min", "By using this, we can control the output of a random number." ], - "tests":[ + "tests": [ "assert(myFunction() >= min, 'message: The random number generated by myFunction should be greater than or equal to the minimum number.');", "assert(myFunction() <= max, 'message: The random number generated by myFunction should be less than or equal to the maximum number.');", "assert(myFunction() % 1 === 0 , 'message: The random number generated by myFunction should be an integer, not a decimal.');", "assert((function(){if(editor.getValue().match(/max/g).length >= 3 && editor.getValue().match(/min/g).length >= 4 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return true;}else{return false;}})(), 'message: You should be using the function given in the description to calculate the random in number in a range.');" ], - "challengeSeed":[ + "challengeSeed": [ "var min = 1;", "var max = 9;", "function myFunction() {", - " // Make myFunction return a random number between min and max values instead of a decimal", + "", " // Only change code below this line.", "", " return Math.random();", - "}", "", "// Only change code above this line.", - "// We use this function to show you the value of your variable in your output box.", + "", + "}", + "", "(function(){return myFunction();})();" ], "type": "waypoint", "challengeType": 1 }, { - "id":"cf1111c1c12feddfaeb3bdef", + "id": "cf1111c1c12feddfaeb3bdef", "title": "Use Conditional Logic with If and Else Statements", - "difficulty":"9.983", - "description":[ + "description": [ "We can use if statements in JavaScript to only execute code if a certain condition is met.", "if statements require some sort of boolean condition to evaluate.", "For example:", @@ -969,13 +1047,13 @@ "Let's use if and else statements to make a coin-flip game.", "Create if and else statements to return the string \"heads\" if the flip variable is zero, or else return the string \"tails\" if the flip variable is not zero." ], - "tests":[ + "tests": [ "assert((function(){var result = myFunction();if(result === 'heads' || result === 'tails'){return true;} else {return false;}})(), 'message: myFunction should either return heads or tails.');", "assert((function(){var result = myFunction();if(result === 'heads' && flip === 0 || result === 'tails' && flip !== 0){return true;} else {return false;}})(), 'message: myFunction should return heads when flip equals 0 and tails when flip equals 1.');", "assert(editor.getValue().match(/if/g).length >= 4, 'message: You should have created a new if statement.');", "assert(editor.getValue().match(/else/g).length >= 2, 'message: You should have created a new else statement.');" ], - "challengeSeed":[ + "challengeSeed": [ "var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;", "function myFunction(){", " // Create an if-else statement here to return \"heads\" if flip is 0. Otherwise return \"tails\".", @@ -994,12 +1072,11 @@ "challengeType": 1 }, { - "id":"cf1111c1c12feddfaeb6bdef", + "id": "cf1111c1c12feddfaeb6bdef", "title": "Sift through Text with Regular Expressions", - "difficulty":"9.984", - "description":[ + "description": [ "Regular expressions are used to find certain words or patterns inside of strings.", - "For example, if we wanted to find the word the in the string The dog chased the cat, we could use the following regular expression: \/the\/gi", + "For example, if we wanted to find the word the in the string The dog chased the cat, we could use the following regular expression: /the/gi", "Let's break this down a bit:", "the is the pattern we want to match.", "g means that we want to search the entire string for this pattern instead of just the first match.", @@ -1007,11 +1084,11 @@ "Regular expressions are written by surrounding the pattern with / symbols.", "Let's try selecting all the occurrences of the word and in the string Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it. We can do this by replacing the . part of our regular expression with the current regular expression with the word and." ], - "tests":[ + "tests": [ "assert(test==2, 'message: Your regular expression should find two occurrences of the word and.');", "assert(editor.getValue().match(/\\/and\\/gi/), 'message: You should have used regular expressions to find the word and.');" ], - "challengeSeed":[ + "challengeSeed": [ "var test = (function() {", " var testString = \"Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it.\";", " var expressionToGetSoftware = /software/gi;", @@ -1028,21 +1105,20 @@ "challengeType": 1 }, { - "id":"cf1111c1c12feddfaeb7bdef", + "id": "cf1111c1c12feddfaeb7bdef", "title": "Find Numbers with Regular Expressions", - "difficulty":"9.985", - "description":[ + "description": [ "We can use special selectors in Regular Expressions to select a particular type of value.", "One such selector is the digit selector \\d which is used to grab the numbers in a string.", "It is used like this: /\\d/g.", "For numbers this is often written as /\\d+/g, where the + following the digit selector allows this regular expression to match multi-digit numbers.", "Use the \\d selector to select the number of numbers in the string, allowing for the possibility of multi-digit numbers." ], - "tests":[ + "tests": [ "assert(test === 2, 'message: Your RegEx should have found two numbers in the testString.');", "assert(editor.getValue().match(/\\/\\\\d\\+\\//g), 'message: You should be using the following expression /\\d+/g to find the numbers in the testString.');" ], - "challengeSeed":[ + "challengeSeed": [ "var test = (function() {", " var testString = \"There are 3 cats but 4 dogs.\";", "", @@ -1059,21 +1135,20 @@ "challengeType": 1 }, { - "id":"cf1111c1c12feddfaeb8bdef", + "id": "cf1111c1c12feddfaeb8bdef", "title": "Find Whitespace with Regular Expressions", - "difficulty":"9.986", - "description":[ + "description": [ "We can also use selectors like \\s to find whitespace in a string.", "The whitespace characters are \" \" (space), \\r (carriage return), \\n (newline), \\t (tab), and \\f (form feed).", "It is used like this:", "/\\s+/g", "Select all the whitespace characters in the sentence string." ], - "tests":[ + "tests": [ "assert(test === 7, 'message: Your RegEx should have found seven spaces in the testString.');", "assert(editor.getValue().match(/\\/\\\\s\\+\\//g), 'message: You should be using the following expression /\\s+/g to find the spaces in the testString.');" ], - "challengeSeed":[ + "challengeSeed": [ "var test = (function(){", " var testString = \"How many spaces are there in this sentence?\";", "", @@ -1090,18 +1165,17 @@ "challengeType": 1 }, { - "id":"cf1111c1c13feddfaeb3bdef", + "id": "cf1111c1c13feddfaeb3bdef", "title": "Invert Regular Expression Matches with JavaScript", - "difficulty":"9.987", - "description":[ + "description": [ "Use /\\S/g to match everything that isn't a space in the string.", "You can invert any match by using the uppercase version of the selector \\s versus \\S for example." ], - "tests":[ + "tests": [ "assert(test === 49, 'message: Your RegEx should have found forty nine non-space characters in the testString.');", "assert(editor.getValue().match(/\\/\\\\S\\/g/g), 'message: You should be using the following expression /\\S/g to find non-space characters in the testString.');" ], - "challengeSeed":[ + "challengeSeed": [ "var test = (function(){", " var testString = \"How many non-space characters are there in this sentence?\";", "", @@ -1115,26 +1189,25 @@ "})();(function(){return test;})();" ], "type": "waypoint", - "challengeType":1 + "challengeType": 1 }, { - "id":"cf1111c1c12feddfaeb9bdef", + "id": "cf1111c1c12feddfaeb9bdef", "title": "Create a JavaScript Slot Machine", - "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.", "For this we will need to generate three random numbers between 1 and 3 to represent the possible values of each individual slot.", "Store the three random numbers in slotOne, slotTwo and slotThree.", "Generate the random numbers by using the system we used earlier (an explanation of the formula can be found here):", "Math.floor(Math.random() * (3 - 1 + 1)) + 1;" ], - "tests":[ + "tests": [ "assert(typeof(runSlots($(\".slot\"))[0]) === \"number\", 'slotOne should be a random number.')", "assert(typeof(runSlots($(\".slot\"))[1]) === \"number\", 'slotTwo should be a random number.')", "assert(typeof(runSlots($(\".slot\"))[2]) === \"number\", 'slotThree should be a random number.')", "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 Math.floor(Math.random() * (3 - 1 + 1)) + 1; three times to generate your random numbers.')" ], - "challengeSeed":[ + "challengeSeed": [ "fccss", " function runSlots(){", " var slotOne;", @@ -1272,10 +1345,9 @@ "challengeType": 0 }, { - "id":"cf1111c1c13feddfaeb1bdef", + "id": "cf1111c1c13feddfaeb1bdef", "title": "Add your JavaScript Slot Machine Slots", - "difficulty":"9.989", - "description":[ + "description": [ "Now that our slots will each generate random numbers, we need to check whether they've all returned the same number.", "If they have, we should notify our user that they've won.", "Otherwise, we should return null, which is a JavaScript data structure that means nothing.", @@ -1285,10 +1357,10 @@ "  return null;", "}" ], - "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.')" ], - "challengeSeed":[ + "challengeSeed": [ "fccss", " function runSlots(){", " var slotOne;", @@ -1432,10 +1504,9 @@ "challengeType": 0 }, { - "id":"cf1111c1c13feddfaeb2bdef", + "id": "cf1111c1c13feddfaeb2bdef", "title": "Bring your JavaScript Slot Machine to Life", - "difficulty":"9.990", - "description":[ + "description": [ "Now we can detect a win. Let's get this slot machine working.", "Let's use the jQuery selector $(\".slot\") to select all of the slots.", "Once they are all selected, we can use bracket notation to access each individual slot:", @@ -1443,11 +1514,11 @@ "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 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((editor.match( /\\$\\s*?\\(\\s*?\\$\\s*?\\(\\s*?(?:'|\")\\s*?\\.slot\\s*?(?:'|\")\\s*?\\)\\[\\d\\]\\s*?\\)/gi) && editor.match( /\\$\\s*?\\(\\s*?\\$\\s*?\\(\\s*?(?:'|\")\\s*?\\.slot\\s*?(?:'|\")\\s*?\\)\\[\\d\\]\\s*?\\)/gi ).length >= 3 && editor.match( /\\.html\\(slotOne\\)/gi ) && editor.match( /\\.html\\(slotTwo\\)/gi ) && editor.match( /\\.html\\(slotThree\\)/gi )), 'You should have used the the selector given in the description to select each slot and assign it the value of slotOne, slotTwo and slotThree respectively.')" ], - "challengeSeed":[ + "challengeSeed": [ "fccss", " function runSlots(){", " var slotOne;", @@ -1598,17 +1669,16 @@ "challengeType": 0 }, { - "id":"cf1111c1c11feddfaeb1bdff", + "id": "cf1111c1c11feddfaeb1bdff", "title": "Give your JavaScript Slot Machine some Stylish Images", - "difficulty":"9.9901", - "description":[ + "description": [ "Now let's add some images to our slots.", "We've already set up the images for you in an array called images. 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:", "$($('.slot')[0]).html('<img src = \"' + images[slotOne-1] + '\">');", "Set up all three slots like this, then click the \"Go\" button to play the slot machine." ], - "tests":[ + "tests": [ "assert((editor.match(/\\$\\s*?\\(\\s*?\\$\\s*?\\(\\s*?(?:'|\")\\s*?\\.slot\\s*?(?:'|\")\\s*?\\)\\[\\d\\]\\s*?\\)\\.html\\(\\s*?\\'\\\\'\\s*?\\);/gi) && editor.match(/\\$\\s*?\\(\\s*?\\$\\s*?\\(\\s*?(?:'|\")\\s*?\\.slot\\s*?(?:'|\")\\s*?\\)\\[\\d\\]\\s*?\\)\\.html\\(\\s*?\\'\\\\'\\s*?\\);/gi).length >= 3), 'Use the provided code three times. One for each slot.')", "assert(editor.match(/\\$\\s*?\\(\\s*?\\$\\s*?\\(\\s*?(?:'|\")\\s*?\\.slot\\s*?(?:'|\")\\s*?\\)\\[0\\]\\s*?\\)/gi), 'You should have used $('.slot')[0] at least once.')", "assert(editor.match(/\\$\\s*?\\(\\s*?\\$\\s*?\\(\\s*?(?:'|\")\\s*?\\.slot\\s*?(?:'|\")\\s*?\\)\\[1\\]\\s*?\\)/gi), 'You should have used $('.slot')[1] at least once.')", @@ -1617,7 +1687,7 @@ "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.')" ], - "challengeSeed":[ + "challengeSeed": [ "fccss", " function runSlots(){", " var slotOne;", @@ -1773,4 +1843,4 @@ "challengeType": 0 } ] -} +} \ No newline at end of file