diff --git a/challenges/basic-javascript.json b/challenges/basic-javascript.json index 75edd1c77a..37b5a82735 100644 --- a/challenges/basic-javascript.json +++ b/challenges/basic-javascript.json @@ -17,9 +17,9 @@ "Try creating one of each." ], "tests":[ - "assert(editor.getValue().match(/(\\/\\*)...../g), 'Create a \/\\* \\*\/ style comment that contains at least five letters.');", - "assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the comment with a \\*\/');", - "assert(editor.getValue().match(/(\\/\\/)...../g), 'Create a \\/\\/ style comment that contains at least five letters');" + "assert(editor.getValue().match(/(\\/\\/)...../g), 'Create a \\/\\/ style comment that contains at least five letters')", + "assert(editor.getValue().match(/(\\/\\*)...../g), 'Create a \/\\* \\*\/ style comment that contains at least five letters.')", + "assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the comment with a \\*\/')" ], "challengeSeed":[ ], @@ -36,8 +36,8 @@ "Let's modify our welcomeToBooleansfunction so that it will return trueinstead of falsewhen the run button is clicked." ], "tests": [ - "assert(typeof(welcomeToBooleans())==\"boolean\", 'The welcomeToBooleans() function should return a boolean (true/false) value.')", - "assert(welcomeToBooleans() == true, 'welcomeToBooleans() should return true.')" + "assert(typeof(welcomeToBooleans()) === 'boolean', 'The welcomeToBooleans() function should return a boolean (true/false) value.')", + "assert(welcomeToBooleans() === true, 'welcomeToBooleans() should return true.')" ], "challengeSeed": [ "function welcomeToBooleans() {", @@ -66,7 +66,7 @@ "Look at the ourName example if you get stuck." ], "tests": [ - "assert((function(){/**/if(typeof(myName) !== \"undefined\" && typeof(myName) == \"string\" && myName.length > 0){return(true);}else{return(false);}/**/})(), 'myName should be a string that contains at least one character in it');" + "assert((function(){/**/if(typeof(myName) !== \"undefined\" && typeof(myName) === \"string\" && myName.length > 0){return(true);}else{return(false);}/**/})(), 'myName should be a string that contains at least one character in it')" ], "challengeSeed": [ "// var ourName = \"Free Code Camp\";", @@ -86,13 +86,12 @@ "title": "Declare String Variables", "difficulty": "9.9802", "description": [ - "In the past challenge, we used the code var myName = \"your name\". This is what we call a String data structure (variable). It is just a \"string\" of characters. JavaScript strings are always wrapped in quotes.", - "Now let's create two new string variables: myFirstNameand myLastName.", - "Assign these variables to equal to your first and last names respectively." + "In the previous challenge, we used the code var myName = \"your name\". This is what we call a String variable. It is nothing more than a \"string\" of characters. JavaScript strings are always wrapped in quotes.", + "Now let's create two new string variables: myFirstNameand myLastName and assign them the values of your first and last name, respectively." ], "tests": [ - "assert((function(){if(typeof(myFirstName) !== \"undefined\" && typeof(myFirstName) == \"string\" && myFirstName.length > 0){return(true);}else{return(false);}})(), 'myFirstName should be a string with a least one character in it');", - "assert((function(){if(typeof(myLastName) !== \"undefined\" && typeof(myLastName) == \"string\" && myLastName.length > 0){return(true);}else{return(false);}})(), 'myLastName should be a string with a least one character in it');" + "assert((function(){if(typeof(myFirstName) !== \"undefined\" && typeof(myFirstName) === \"string\" && myFirstName.length > 0){return(true);}else{return(false);}})(), 'myFirstName should be a string with a least one character in it')", + "assert((function(){if(typeof(myLastName) !== \"undefined\" && typeof(myLastName) === \"string\" && myLastName.length > 0){return(true);}else{return(false);}})(), 'myLastName should be a string with a least one character in it')" ], "challengeSeed": [ "// ourName = \"Free Code Camp\";", @@ -114,20 +113,20 @@ "difficulty": "9.9809", "description": [ "Use the .length property to count the number of characters in the lastNameLength variable.", - "For example, if we created a variable var firstName = \"Julie\", we could find out how long the string \"Julie\" is by using the firstName.length property." + "For example, if we created a variable var firstName = \"Charles\", we could find out how long the string \"Charles\" is by using the firstName.length property." ], "tests": [ - "assert((function(){if(typeof(lastNameLength) != \"undefined\" && typeof(lastNameLength) == \"number\" && lastNameLength == 4){return(true);}else{return(false);}})(), 'lastNameLength should be equal to four')", - "assert((function(){if(editor.getValue().match(/\\.length/gi) && editor.getValue().match(/\\.length/gi).length >= 2 && editor.getValue().match(/var lastNameLength \\= 0;/gi) && editor.getValue().match(/var lastNameLength \\= 0;/gi).length >= 1){return(true);}else{return(false);}})(), 'You should be getting the length of lastName by using .length like this: lastName.length');" + "assert((function(){if(typeof(lastNameLength) != \"undefined\" && typeof(lastNameLength) === \"number\" && lastNameLength === 8){return(true);}else{return(false);}})(), 'lastNameLength should be equal to eight.')", + "assert((function(){if(editor.getValue().match(/\\.length/gi) && editor.getValue().match(/\\.length/gi).length >= 2 && editor.getValue().match(/var lastNameLength \\= 0;/gi) && editor.getValue().match(/var lastNameLength \\= 0;/gi).length >= 1){return(true);}else{return(false);}})(), 'You should be getting the length of lastName by using .length like this: lastName.length')" ], "challengeSeed": [ "var firstNameLength = 0;", "var lastNameLength = 0;", - "var firstName = \"Madeline\";", + "var firstName = \"Ada\";", "", "firstNameLength = firstName.length;", "", - "var lastName = \"Chen\";", + "var lastName = \"Lovelace\";", "", "lastNameLength = lastName;", "", @@ -146,24 +145,24 @@ "title": "Use Bracket Notation to Find the First Character in a String", "difficulty": "9.9810", "description": [ - "Use bracket notation to find the first character in a the firstLetterOfLastName variable.", "Bracket notation is a way to get a character at a specific index within a string.", "Computers don't start counting at 1 like humans do. They start at 0.", - "For example, the character at index 0 in the word \"Julie\" is \"J\". So if var firstName = \"Julie\", you can get the value of the first letter of the string by using firstName[0].", + "For example, the character at index 0 in the word \"Charles\" is \"C\". So if var firstName = \"Charles\", you can get the value of the first letter of the string by using firstName[0].", + "Use bracket notation to find the first character in a the firstLetterOfLastName variable.", "Try looking at the firstLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "assert((function(){if(typeof(firstLetterOfLastName) != \"undefined\" && editor.getValue().match(/\\[0\\]/gi) && typeof(firstLetterOfLastName) == \"string\" && firstLetterOfLastName == \"C\"){return(true);}else{return(false);}})(), 'The first letter of firstLetterOfLastName should be a C');" + "assert((function(){if(typeof(firstLetterOfLastName) != \"undefined\" && editor.getValue().match(/\\[0\\]/gi) && typeof(firstLetterOfLastName) === \"string\" && firstLetterOfLastName === \"L\"){return(true);}else{return(false);}})(), 'The first letter of firstLetterOfLastName should be a L')" ], "challengeSeed": [ "var firstLetterOfLastName = \"\"", "var firstLetterOfLastName = \"\"", "", - "var firstName = \"Madeline\";", + "var firstName = \"Ada\";", "", "firstLetterOfFirstName = firstName[0];", "", - "var lastName = \"Chen\";", + "var lastName = \"Lovelace\";", "", "firstLetterOfLastName = lastName;", "", @@ -181,20 +180,20 @@ "title": "Use Bracket Notation to Find the Nth Character in a String", "difficulty": "9.9811", "description": [ - "Just like the last lesson where we used Bracket Notationto access the first letter we can use the same method to get the letters ar other positions", - "Don't forget that computers start counting at 0 so the first letter is actually the zeroth one", - "Let's now try to set thirdLetterOfLastNameto equal the third letter of the lastNamevariable", + "You can also use bracket Notationto get the character at other positions within a string.", + "Remember that computers start counting at 0, so the first character is actually the zeroth character.", + "Let's try to set thirdLetterOfLastNameto equal the third letter of the lastName variable.", "Try looking at the secondLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "assert(thirdLetterOfLastName == \"e\", 'The third last letter of lastName should be an e');" + "assert(thirdLetterOfLastName === 'v', 'The third last letter of lastName should be a \"v\"')" ], "challengeSeed": [ - "var firstName = \"Madeline\";", + "var firstName = \"Ada\";", "", "var secondLetterOfFirstName = firstName[1];", "", - "var lastName = \"Chen\";", + "var lastName = \"Lovelace\";", "", "var thirdLetterOfLastName = lastName;", "", @@ -212,22 +211,21 @@ "title": "Use Bracket Notation to Find the Last Character in a String", "difficulty": "9.9812", "description": [ - "Use bracket notation to find the last character in the lastName variable.", - "For example, the character at index 0 in the word \"Julie\" is \"J\". So if var firstName = \"Julie\", you can get the value of the first letter of the string by using firstName[0].", "In order to get the last letter of a string, you can subtract one from the string's length.", - "For example, if var firstName = \"Julie\", you can get the value of the last letter of the string by using firstName[firstName.length - 1].", + "For example, if var firstName = \"Charles\", you can get the value of the last letter of the string by using firstName[firstName.length - 1].", + "Use bracket notation to find the last character in the lastName variable.", "Try looking at the lastLetterOfLastName variable declaration if you get stuck." ], "tests": [ - "assert(lastLetterOfLastName == \"n\", 'lastLetterOfLastName should be n');", - "assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the last letter');" + "assert(lastLetterOfLastName === \"e\", 'lastLetterOfLastName should be \"e\"')", + "assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the last letter')" ], "challengeSeed": [ - "var firstName = \"Madeline\";", + "var firstName = \"Ada\";", "", "var lastLetterOfFirstName = firstName[firstName.length - 1];", "", - "var lastName = \"Chen\";", + "var lastName = \"Lovelace\";", "", "var lastLetterOfLastName = lastName;", "", @@ -245,22 +243,21 @@ "title": "Use Bracket Notation to Find the Nth-to-Last Character in a String", "difficulty": "9.9813", "description": [ - "Use bracket notation to find the second-to-last character in the lastName variable.", - "For example, the character at index 0 in the word \"Julie\" is \"J\". So if var firstName = \"Julie\", you can get the value of the first letter of the string by using firstName[0].", "In order to get the last letter of a string, you can subtract one from the string's length.", - "For example, if var firstName = \"Julie\", you can get the value of the third-to-last letter of the string by using firstName[firstName.length - 3].", + "For example, you can get the value of the third-to-last letter of the var firstName = \"Charles\" string by using firstName[firstName.length - 3].", + "Use bracket notation to find the second-to-last character in the lastName string.", "Try looking at the lastLetterOfLastName variable declaration if you get stuck." ], "tests": [ - "assert(secondToLastLetterOfLastName == \"e\", 'secondToLastLetterOfLastName should be e');", - "assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the third last letter');" + "assert(secondToLastLetterOfLastName === 'c', 'secondToLastLetterOfLastName should be \"c\".')", + "assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the third last letter.')" ], "challengeSeed": [ - "var firstName = \"Madeline\";", + "var firstName = \"Ada\";", "", "var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];", "", - "var lastName = \"Chen\";", + "var lastName = \"Lovelace\";", "", "var secondToLastLetterOfLastName = lastName;", "", @@ -278,23 +275,20 @@ "title": "Add Two Numbers with JavaScript", "difficulty": "9.98141", "description": [ - "In JavaScript whole numbers (called integers) can be easily used to perform mathematical functions.", - "Let's try a few of the most commonly used ones now.", - "We use +for addition.", - "Replace the 0with correct number to achieve the result in the comment." + "Let's try to add two numbers using JavaScript.", + "JavaScript uses the + symbol for addition.", + "Replace the 0 with the right number so you can get the result mentioned in the comment." ], "tests": [ - "assert((function(){if(add == 20 && editor.getValue().match(/\\+/g)){return(true);}else{return(false);}})(), 'Add should be the result of a sum and be equal to 20');" + "assert((function(){if(sum === 20 && editor.getValue().match(/\\+/g)){return(true);}else{return(false);}})(), 'Make the variable sum equal 20')" ], "challengeSeed": [ - "var add = 10 + 0;//equals 20", - "", - "", + "var sum = 10 + 0; //make this equal to 20 by changing the 0 into the appropriate number.", "", "// You can ignore everything below 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('add='+z);})(add);" + "(function(z){return('sum='+z);})(sum);" ], "type": "waypoint", "challengeType": 1 @@ -304,23 +298,20 @@ "title": "Subtract One Number from Another with JavaScript", "difficulty": "9.98142", "description": [ - "In JavaScript whole numbers (called integers) can be easily used to perform mathematical functions.", - "Let's try a few of the most commonly used ones now.", - "We use -for subtraction.", - "Replace the 0with correct number to achieve the result in the comment." + "We can also subtract one number from another.", + "JavaScript uses use the - symbol for subtraction.", + "Replace the 0 with the right number so you can get the result mentioned in the comment." ], "tests": [ - "assert((function(){if(subtract == 12 && editor.getValue().match(/\\-/g)){return(true);}else{return(false);}})(), 'Subtract should be the result of a sum and be equal to 12');" + "assert((function(){if(difference === 12 && editor.getValue().match(/\\-/g)){return(true);}else{return(false);}})(), 'Make the variable difference equal 12')" ], "challengeSeed": [ - "var subtract = 45 - 0;//equals 12", - "", - "", + "var difference = 45 - 0; //make this equal to 12 by changing the 0 into the appropriate number.", "", "// You can ignore everything below 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('subtract='+z);})(subtract);" + "(function(z){return('difference='+z);})(difference);" ], "type": "waypoint", "challengeType": 1 @@ -330,23 +321,20 @@ "title": "Multiply Two Numbers with JavaScript", "difficulty": "9.98143", "description": [ - "In JavaScript whole numbers (called integers) can be easily used to perform mathematical functions.", - "Let's try a few of the most commonly used ones now.", - "We use *for multiplication.", - "Replace the 0with correct number to achieve the result in the comment." + "We can also multiply one number by another.", + "JavaScript uses use the * symbol for multiplication.", + "Replace the 0 with the right number so you can get the result mentioned in the comment." ], "tests": [ - "assert((function(){if(multiply == 80 && editor.getValue().match(/\\*/g)){return(true);}else{return(false);}})(), 'Multiply should be the result of a sum and be equal to 80');" + "assert((function(){if(product === 80 && editor.getValue().match(/\\*/g)){return(true);}else{return(false);}})(), 'Make the variable product equal 80.')" ], "challengeSeed": [ - "var multiply = 8 * 0;//equals 80", - "", - "", + "var product = 8 * 0; //make this equal to 80 by changing the 0 into the appropriate number.", "", "// You can ignore everything below 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('multiply='+z);})(multiply);" + "(function(z){return('product='+z);})(product)" ], "type": "waypoint", "challengeType": 1 @@ -356,23 +344,20 @@ "title": "Divide One Number by Another with JavaScript", "difficulty": "9.9814", "description": [ - "In JavaScript whole numbers (called integers) can be easily used to perform mathematical functions.", - "Let's try a few of the most commonly used ones now.", - "We use /for division.", - "Replace the 0with correct number to achieve the result in the comment." + "We can also divide one number by another.", + "JavaScript uses use the / symbol for division.", + "Replace the 0 with the right number so you can get the result mentioned in the comment." ], "tests": [ - "assert((function(){if(divide == 2 && editor.getValue().match(/\\//g)){return(true);}else{return(false);}})(), 'Divide should be the result of a sum and be equal to 2');" + "assert((function(){if(quotient === 2 && editor.getValue().match(/\\//g)){return(true);}else{return(false);}})(), 'Make the variable quotient equal 2.)" ], "challengeSeed": [ - "var divide = 66 / 0;//equals 2", - "", - "", + "var quotient = 66 / 0; //make this equal to 2 by changing the 0 into the appropriate number.", "", "// You can ignore everything below 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('divide='+z);})(divide);" + "(function(z){return('quotient='+z);})(quotient);" ], "type": "waypoint", "challengeType": 1 @@ -382,16 +367,15 @@ "title": "Create Decimal Numbers with JavaScript", "difficulty": "9.9815", "description": [ - "In JavaScript we can work with decimal numbers.", + "JavaScript number variables can also have decimals.", "Let's create a variable myDecimal and give it a decimal value." ], "tests": [ - "assert((function(){if(typeof(myDecimal) != \"undefined\" && typeof(myDecimal) == \"number\" && editor.getValue().match(/\\./g).length >=2){return(true);}else{return(false);}})(), 'myDecimal should be a decimal point number');" + "assert((function(){if(typeof(myDecimal) != \"undefined\" && typeof(myDecimal) === \"number\" && editor.getValue().match(/\\./g).length >=2){return(true);}else{return(false);}})(), '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", + "// Create a number with a decimal point here called myDecimal", "", "", "", @@ -411,8 +395,8 @@ "In JavaScript we can work with decimal numbers." ], "tests": [ - "assert(multiply == 15, 'The result of multiply should be 3.75');", - "assert(divide == 2.25, 'The result of divide should be 2.25');" + "assert(multiply === 15, 'The result of multiply should be 3.75.')", + "assert(divide === 2.25, 'The result of divide should be 2.25.')" ], "challengeSeed": [ "var multiply = 3.75 * 0;//equals 15", @@ -439,9 +423,9 @@ "Refer to the example if you get stuck." ], "tests": [ - "assert(typeof(myArray) == \"object\", 'myArray should be an array');", - "assert(typeof(myArray[0]) !== \"undefined\" && typeof(myArray[0]) == \"string\", 'The fist item in myArray should be a string');", - "assert(typeof(myArray[1]) !== \"undefined\" && typeof(myArray[1]) == \"number\", 'The second item in myArray should be a number');" + "assert(typeof(myArray) === \"object\", 'myArray should be an array')", + "assert(typeof(myArray[0]) !== \"undefined\" && typeof(myArray[0]) === \"string\", 'The fist item in myArray should be a string')", + "assert(typeof(myArray[1]) !== \"undefined\" && typeof(myArray[1]) === \"number\", 'The second item in myArray should be a number')" ], "challengeSeed": [ "//var array = [\"John\", 23];", @@ -466,7 +450,7 @@ "Let's now go create a nested array called myArray" ], "tests":[ - "assert((function(){if(typeof(myArray) !== \"undefined\" && typeof(myArray) === \"object\" && typeof(myArray[0]) !== \"undefined\" && typeof(myArray[0]) === \"object\" && editor.getValue().match(/\\[\\[/g).length >= 1 && editor.getValue().match(/\\]\\]/g).length >= 1){return(true);}else{return(false);}})(), 'myArray should contain at least one array');" + "assert((function(){if(typeof(myArray) !== \"undefined\" && typeof(myArray) === \"object\" && typeof(myArray[0]) !== \"undefined\" && typeof(myArray[0]) === \"object\" && editor.getValue().match(/\\[\\[/g).length >= 1 && editor.getValue().match(/\\]\\]/g).length >= 1){return(true);}else{return(false);}})(), 'myArray should contain at least one array')" ], "challengeSeed":[ "var myArray = [];", @@ -495,7 +479,7 @@ "Create a var called data and set it to equal the first value of myArray" ], "tests":[ - "assert((function(){if(typeof(myArray) != \"undefined\" && typeof(data) != \"undefined\" && myArray[0] == data){return(true);}else{return(false);}})(), 'the variable data should equal the first value of myArray');" + "assert((function(){if(typeof(myArray) != \"undefined\" && typeof(data) != \"undefined\" && myArray[0] === data){return(true);}else{return(false);}})(), 'the variable data should equal the first value of myArray')" ], "challengeSeed":[ "//var ourArray = [1,2,3]", @@ -527,8 +511,8 @@ "Now Let's modify myArray using an index." ], "tests":[ - "assert((function(){if(typeof(myArray) != \"undefined\" && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return(true);}else{return(false);}})(), 'myArray should now be [3,2,3]');", - "assert((function(){if(editor.getValue().match(/[0]/g).length >= 2 && editor.getValue().match(/=/g).length >= 2){return(true);}else{return(false);}})(), 'You should be using indexes to modify the values in myArray');" + "assert((function(){if(typeof(myArray) != \"undefined\" && myArray[0] === 3 && myArray[1] === 2 && myArray[2] === 3){return(true);}else{return(false);}})(), 'myArray should now be [3,2,3]')", + "assert((function(){if(editor.getValue().match(/[0]/g).length >= 2 && editor.getValue().match(/=/g).length >= 2){return(true);}else{return(false);}})(), 'You should be using indexes to modify the values in myArray')" ], "challengeSeed":[ "//var ourArray = [1,2,3];", @@ -559,8 +543,8 @@ "Let's try .pop()now" ], "tests": [ - "assert((function(d){if(d[0] == \"John\" && d[1] == 23 && d[2] == undefined){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23])');", - "assert((function(d){if(d[0] == \"cat\" && d[1] == 2 && d[2] == undefined){return(true);}else{return(false);}})(removed), 'myArray should only have the first two values left([\"cat\"], 2)');" + "assert((function(d){if(d[0] === \"John\" && d[1] === 23 && d[2] === undefined){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23])')", + "assert((function(d){if(d[0] === \"cat\" && d[1] === 2 && d[2] === undefined){return(true);}else{return(false);}})(removed), 'myArray should only have the first two values left([\"cat\"], 2)')" ], "challengeSeed": [ "//var numbers = [1,2,3];", @@ -590,7 +574,7 @@ "Let's take the code we had last time and pushthis value to the end: [\"dog\", 3] " ], "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), 'myArray should only have the first two values left([\"John\", 23, [\"dog\", 3]])');" + "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), 'myArray should only have the first two values left([\"John\", 23, [\"dog\", 3]])')" ], "challengeSeed": [ "var myArray = [\"John\", 23, [\"cat\", 2]];", @@ -616,8 +600,8 @@ "Let's try .shift()now" ], "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), 'myArray should only have the first two values left([\"John\", 23])');", - "assert((function(d){if(d === \"John\" && typeof(removed) === \"string\"){return(true);}else{return(false);}})(removed), 'Removed should contain \"John\"');" + "assert((function(d){if(d[0] === 23 && d[1][0] === \"dog\" && d[1][1] === 3 && d[2] === undefined){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23])')", + "assert((function(d){if(d === \"John\" && typeof(removed) === \"string\"){return(true);}else{return(false);}})(removed), 'Removed should contain \"John\"')" ], "challengeSeed": [ "var myArray = [\"John\", 23, [\"dog\", 3]];", @@ -641,7 +625,7 @@ "Let's take the code we had last time and unshiftthis value to the end: \"Paul\" " ], "tests": [ - "assert((function(d){if(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), 'myArray should now have [\"Paul\", 23, [\"dog\", 3]])');" + "assert((function(d){if(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), 'myArray should now have [\"Paul\", 23, [\"dog\", 3]])')" ], "challengeSeed": [ "var myArray = [\"John\", 23, [\"dog\", 3]];", @@ -674,7 +658,7 @@ "Let's try creating and calling a function now called myFunction" ], "tests":[ - "assert((function(){if(typeof(f) !== \"undefined\" && typeof(f) === \"number\" && f === a + b && editor.getValue().match(/return/gi).length >= 1 && editor.getValue().match(/a/gi).length >= 1 && editor.getValue().match(/b/gi).length >= 1 && editor.getValue().match(/\\+/gi).length >= 1){return(true);}else{return(false);}})(), 'Your function should return the value of a + b');" + "assert((function(){if(typeof(f) !== \"undefined\" && typeof(f) === \"number\" && f === a + b && editor.getValue().match(/return/gi).length >= 1 && editor.getValue().match(/a/gi).length >= 1 && editor.getValue().match(/b/gi).length >= 1 && editor.getValue().match(/\\+/gi).length >= 1){return(true);}else{return(false);}})(), 'Your function should return the value of a + b')" ], "challengeSeed":[ "var a = 4;", @@ -716,10 +700,10 @@ "Let's try to make an Object that represents a dog called myDog!" ], "tests":[ - "assert((function(z){if(z.hasOwnProperty(\"name\") && z.name != undefined && typeof(z.name) == \"string\"){return(true);}else{return(false);}})(myDog), '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), '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), '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), 'myDog should contain the property friends and it should be an array');" + "assert((function(z){if(z.hasOwnProperty(\"name\") && z.name != undefined && typeof(z.name) === \"string\"){return(true);}else{return(false);}})(myDog), '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), '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), '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), 'myDog should contain the property friends and it should be an array')" ], "challengeSeed":[ "//var ourDog = {", @@ -757,8 +741,8 @@ "" ], "tests":[ - "assert(myDog.bark != undefined, 'You should have added the property bark to myDog');", - "assert(myDog.tails == undefined, 'The property tails should have been deleted');" + "assert(myDog.bark != undefined, 'You should have added the property bark to myDog')", + "assert(myDog.tails === undefined, 'The property tails should have been deleted')" ], "challengeSeed":[ "//var ourDog = {", @@ -807,8 +791,8 @@ "Let's try getting a for loop to work by pushing values to an array" ], "tests":[ - "assert(editor.getValue().match(/for\\(/g), 'You should be using a for loop for this.');", - "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + "assert(editor.getValue().match(/for\\(/g), 'You should be using a for loop for this.')", + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]')" ], "challengeSeed":[ "var myArray = [];", @@ -837,8 +821,8 @@ "Let's try getting a for loop to work by pushing values to an array" ], "tests":[ - "assert(editor.getValue().match(/while\\(/g), 'You should be using a while loop for this.');", - "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');" + "assert(editor.getValue().match(/while\\(/g), 'You should be using a while loop for this.')", + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]')" ], "challengeSeed":[ "var myArray = [];", @@ -867,8 +851,8 @@ "Let's try getting a do - while loop to work by pushing values to an array" ], "tests":[ - "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');", - "assert((function(){if(editor.getValue().match(/do/g) && editor.getValue(/while/g).match()){return(true);}else{return(false);}})(), 'You should be using a do while loop for this.');" + "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]')", + "assert((function(){if(editor.getValue().match(/do/g) && editor.getValue(/while/g).match()){return(true);}else{return(false);}})(), 'You should be using a do while loop for this.')" ], "challengeSeed":[ "var myArray = [];", @@ -889,9 +873,9 @@ "Let's have a go of Math.random() now be getting myFunction to return a random number" ], "tests":[ - "assert(typeof(myFunction()) === \"number\", 'myFunction should return a random number');", - "assert((myFunction()+''). match(/\\./g), 'The number returned by myFunction should be a decimal');", - "assert(editor.getValue().match(/Math\\.random/g).length >= 2, 'You should be using Math.random to generate the random decimal number');" + "assert(typeof(myFunction()) === \"number\", 'myFunction should return a random number')", + "assert((myFunction()+''). match(/\\./g), 'The number returned by myFunction should be a decimal')", + "assert(editor.getValue().match(/Math\\.random/g).length >= 2, 'You should be using Math.random to generate the random decimal number')" ], "challengeSeed":[ "", @@ -920,10 +904,10 @@ "Let's give this technique a go now" ], "tests":[ - "assert(typeof(myFunction()) == \"number\", 'The result of myFunction should be a number');", - "assert(editor.getValue().match(/Math.random/g), 'You should be using Math.random to create a random number');", - "assert(!(''+myFunction()).match(/\\./g), 'You should have multiplied the result of Math.random but 10 to make it a number that\\'s greater then zero');", - "assert(editor.getValue().match(/Math.floor/g), 'You should use Math.floor to remove the decimal part of the number');" + "assert(typeof(myFunction()) === \"number\", 'The result of myFunction should be a number')", + "assert(editor.getValue().match(/Math.random/g), 'You should be using Math.random to create a random number')", + "assert(!(''+myFunction()).match(/\\./g), 'You should have multiplied the result of Math.random but 10 to make it a number that\\'s greater then zero')", + "assert(editor.getValue().match(/Math.floor/g), 'You should use Math.floor to remove the decimal part of the number')" ], "challengeSeed":[ "function myFunction(){", @@ -949,9 +933,9 @@ "" ], "tests":[ - "assert(myFunction() >= min, 'The random number that\\'s generated by myFunction should be greater than or equal to the minimum number');", - "assert(myFunction() <= max, 'The random number that\\'s generated by myFunction should be less than or equal to the maximum number');", - "assert((function(){if(editor.getValue().match(/max/g).length >= 2 && editor.getValue().match(/min/g).length >= 3 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return(true);}else{return(false);}})(), 'You should be using the function given in the description to calculate the random in number in a range');" + "assert(myFunction() >= min, 'The random number that\\'s generated by myFunction should be greater than or equal to the minimum number')", + "assert(myFunction() <= max, 'The random number that\\'s generated by myFunction should be less than or equal to the maximum number')", + "assert((function(){if(editor.getValue().match(/max/g).length >= 2 && editor.getValue().match(/min/g).length >= 3 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return(true);}else{return(false);}})(), 'You should be using the function given in the description to calculate the random in number in a range')" ], "challengeSeed":[ " var min = 0;", @@ -986,9 +970,9 @@ "Create an if else statement to return heads if the flip var is zero and to return tails if it's not" ], "tests":[ - "assert((function(){if(myFunction() == \"heads\" || myFunction() == \"tails\"){return(true);}else{return(false);}})(), 'myFunction should either return heads or tails');", - "assert(editor.getValue().match(/if/g).length >= 3, 'You should have created a new if statement');", - "assert(editor.getValue().match(/else/g).length >= 2, 'You should have created a new else statement');" + "assert((function(){if(myFunction() === \"heads\" || myFunction() === \"tails\"){return(true);}else{return(false);}})(), 'myFunction should either return heads or tails')", + "assert(editor.getValue().match(/if/g).length >= 3, 'You should have created a new if statement')", + "assert(editor.getValue().match(/else/g).length >= 2, 'You should have created a new else statement')" ], "challengeSeed":[ "function myFunction(){", @@ -1021,8 +1005,8 @@ "Let's try finding the word and in the string \"John and Alan went to the shop and got some milk\" by replacing the .+ in the currnet RegEx with something that will find the word \"and\" and count how many times it occurs" ], "tests":[ - "assert(test==2, 'You\\'re RegEx should have found two occurances of the word \"and\"');", - "assert(editor.getValue().match(/\\/and\\+\\/gi/), 'You should have used this RegEx to find the word \"and\"');" + "assert(test==2, 'You\\'re RegEx should have found two occurances of the word \"and\"')", + "assert(editor.getValue().match(/\\/and\\+\\/gi/), 'You should have used this RegEx to find the word \"and\"')" ], "challengeSeed":[ "var test = (function(){", @@ -1051,8 +1035,8 @@ "/\\d+/g" ], "tests":[ - "assert(test === 2, 'Your RegEx should have found two numbers in the testString');", - "assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'You should be using the following expression /\\d+/gi to find the numbers in the testString');" + "assert(test === 2, 'Your RegEx should have found two numbers in the testString')", + "assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'You should be using the following expression /\\d+/gi to find the numbers in the testString')" ], "challengeSeed":[ "var test = (function(){", @@ -1080,8 +1064,8 @@ "/\\s+/g" ], "tests":[ - "assert(test === 7, 'Your RegEx should have found seven spaces in the testString');", - "assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'You should be using the following expression /\\s+/gi to find the spaces in the testString');" + "assert(test === 7, 'Your RegEx should have found seven spaces in the testString')", + "assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'You should be using the following expression /\\s+/gi to find the spaces in the testString')" ], "challengeSeed":[ "var test = (function(){", @@ -1108,8 +1092,8 @@ "You can invert any match by using the uppercase version of the selector \\s versus \\S for example" ], "tests":[ - "assert(test === 36, 'Your RegEx should have found seven spaces in the testString');", - "assert(editor.getValue().match(/\\/\\\\S\\/gi/gi), 'You should be using the following expression /\\S+/gi to find the spaces in the testString');" + "assert(test === 36, 'Your RegEx should have found seven spaces in the testString')", + "assert(editor.getValue().match(/\\/\\\\S\\/gi/gi), 'You should be using the following expression /\\S+/gi to find the spaces in the testString')" ], "challengeSeed":[ "var test = (function(){", @@ -1139,10 +1123,10 @@ "Math.floor(Math.random() * (5 - 1 + 1)) + 1; " ], "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?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 Math.floor(Math.random() * (5 - 1 + 1)) + 1; three times to generate your random numbers');" + "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?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 Math.floor(Math.random() * (5 - 1 + 1)) + 1; three times to generate your random numbers')" ], "challengeSeed":[ "fccss", @@ -1295,7 +1279,7 @@ "}" ], "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":[ "fccss", @@ -1453,8 +1437,8 @@ "Use the above selector to display each number in the corresponding slot" ], "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(){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, slotTwo and slotThree respectively');" + "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, slotTwo and slotThree respectively')" ], "challengeSeed":[ "fccss", @@ -1616,10 +1600,10 @@ "$($('.slot')[0]).html('<img src = \"' + images[slotOne-1] + '\">');" ], "tests":[ - "assert(editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\\\'\\);/gi) && editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\\\'\\);/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(/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(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\\\'\\);/gi) && editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\\\'\\);/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(/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":[ "fccss", @@ -1635,7 +1619,7 @@ " slotTwo = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotThree = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " ", - " $('.logger').html('');", + " $('.logger').html('')", " $('.logger').html('Not A Win')", " ", " /*Don't modify above this line*/", diff --git a/challenges/object-oriented-and-functional-programming.json b/challenges/object-oriented-and-functional-programming.json index 3f76e39014..0d815b3635 100644 --- a/challenges/object-oriented-and-functional-programming.json +++ b/challenges/object-oriented-and-functional-programming.json @@ -19,9 +19,9 @@ "Before we dive into Object Oriented Programming Let's take a quick look over objects in javascript" ], "tests":[ - "assert(motorBike.wheels===2, 'You should have given motorBike two wheels');", - "assert(motorBike.engine===1, 'You should have given motorBike one engine');", - "assert(motorBike.seats===1, 'You should have given motorBike one seat');" + "assert(motorBike.wheels===2, 'You should have given motorBike two wheels')", + "assert(motorBike.engine===1, 'You should have given motorBike one engine')", + "assert(motorBike.seats===1, 'You should have given motorBike one seat')" ], "challengeSeed":[ "//Here is a sample Object", @@ -53,8 +53,8 @@ ], "tests":[ "assert((new Car()).wheels === 4, \"myCar.wheels should be four. Make sure that you haven't changed this value\");", - "assert(typeof((new Car()).engine) === 'number', 'myCar.engine should be a number');", - "assert(typeof((new Car()).seats) === 'number', 'myCar.seats should be a number');" + "assert(typeof((new Car()).engine) === 'number', 'myCar.engine should be a number')", + "assert(typeof((new Car()).seats) === 'number', 'myCar.seats should be a number')" ], "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", @@ -79,9 +79,9 @@ "We can also create variables and functions that aren't accessible from outside the Object" ], "tests":[ - "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.addUnit === 'undefined'), '');" + "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.addUnit === 'undefined'), '')" ], "challengeSeed":[ "//Let's create an object with a two functions. One attached as a property and one not.", @@ -127,10 +127,10 @@ "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');", - "assert(typeof((new Car()).engine) === 'undefined', 'There should not be a property engine in the object constructor');", - "assert(myCar.wheels === 4, 'The property wheels of myCar should be four');", - "assert(typeof(myCar.engine) === 'number', 'The property engine of myCar should be a number');" + "assert((new Car()).wheels === 4, 'The property wheels should be four in the object constructor')", + "assert(typeof((new Car()).engine) === 'undefined', 'There should not be a property engine in the object constructor')", + "assert(myCar.wheels === 4, 'The property wheels of myCar should be four')", + "assert(typeof(myCar.engine) === 'number', 'The property engine of myCar should be a number')" ], "challengeSeed":[ "var Car = function(){", @@ -159,9 +159,9 @@ "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.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');" + "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":[ "//Use map to add three to each value in the array", @@ -186,8 +186,8 @@ "}" ], "tests":[ - "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');" + "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":[ "var array = [4,5,6,7,8];", @@ -213,8 +213,8 @@ "});" ], "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(editor.getValue().match(/array\\.filter\\(/gi), 'You should be using the filter method to remove the values from the array');", + "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":[ @@ -239,9 +239,9 @@ "" ], "tests":[ - "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');" + "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":[ "var array = ['beta', 'alpha', 'charlie'];", @@ -261,9 +261,9 @@ "You can use the reverse method to reverse the contents of an array" ], "tests": [ - "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), '');" + "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": [ "var array = [1,2,3,4,5,6,7];", @@ -284,9 +284,9 @@ "array = array.concat(otherArray);" ], "tests": [ - "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');" + "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": [ "var array = [1,2,3];", @@ -310,8 +310,8 @@ "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');" + "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\";", @@ -332,8 +332,8 @@ "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');" + "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\"];",