make additional improvements to JavaScript challenge copy

This commit is contained in:
Quincy Larson
2015-08-13 23:44:13 -07:00
parent edf9959fc9
commit cd4fd1720d
2 changed files with 159 additions and 175 deletions

View File

@ -17,9 +17,9 @@
"Try creating one of each." "Try creating one of each."
], ],
"tests":[ "tests":[
"assert(editor.getValue().match(/(\\/\\*)...../g), 'Create a <code>\/\\* \\*\/</code> style comment that contains at least five letters.');", "assert(editor.getValue().match(/(\\/\\/)...../g), 'Create a <code>\\/\\/</code> style comment that contains at least five letters')",
"assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the comment with a <code>\\*\/</code>');", "assert(editor.getValue().match(/(\\/\\*)...../g), 'Create a <code>\/\\* \\*\/</code> style comment that contains at least five letters.')",
"assert(editor.getValue().match(/(\\/\\/)...../g), 'Create a <code>\\/\\/</code> style comment that contains at least five letters');" "assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the comment with a <code>\\*\/</code>')"
], ],
"challengeSeed":[ "challengeSeed":[
], ],
@ -36,8 +36,8 @@
"Let's modify our <code>welcomeToBooleans</code>function so that it will return <code>true</code>instead of <code>false</code>when the run button is clicked." "Let's modify our <code>welcomeToBooleans</code>function so that it will return <code>true</code>instead of <code>false</code>when the run button is clicked."
], ],
"tests": [ "tests": [
"assert(typeof(welcomeToBooleans())==\"boolean\", 'The <code>welcomeToBooleans()</code> function should return a boolean (true/false) value.')", "assert(typeof(welcomeToBooleans()) === 'boolean', 'The <code>welcomeToBooleans()</code> function should return a boolean &#40;true/false&#41; value.')",
"assert(welcomeToBooleans() == true, '<code>welcomeToBooleans()</code> should return true.')" "assert(welcomeToBooleans() === true, '<code>welcomeToBooleans()</code> should return true.')"
], ],
"challengeSeed": [ "challengeSeed": [
"function welcomeToBooleans() {", "function welcomeToBooleans() {",
@ -66,7 +66,7 @@
"Look at the <code>ourName</code> example if you get stuck." "Look at the <code>ourName</code> example if you get stuck."
], ],
"tests": [ "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": [ "challengeSeed": [
"// var ourName = \"Free Code Camp\";", "// var ourName = \"Free Code Camp\";",
@ -86,13 +86,12 @@
"title": "Declare String Variables", "title": "Declare String Variables",
"difficulty": "9.9802", "difficulty": "9.9802",
"description": [ "description": [
"In the past challenge, we used the code <code>var myName = \"your name\"</code>. This is what we call a <code>String</code> data structure (variable). It is just a \"string\" of characters. JavaScript strings are always wrapped in quotes.", "In the previous challenge, we used the code <code>var myName = \"your name\"</code>. This is what we call a <code>String</code> 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: <code>myFirstName</code>and <code>myLastName</code>.", "Now let's create two new string variables: <code>myFirstName</code>and <code>myLastName</code> and assign them the values of your first and last name, respectively."
"Assign these variables to equal to your first and last names respectively."
], ],
"tests": [ "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(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(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": [ "challengeSeed": [
"// ourName = \"Free Code Camp\";", "// ourName = \"Free Code Camp\";",
@ -114,20 +113,20 @@
"difficulty": "9.9809", "difficulty": "9.9809",
"description": [ "description": [
"Use the <code>.length</code> property to count the number of characters in the <code>lastNameLength</code> variable.", "Use the <code>.length</code> property to count the number of characters in the <code>lastNameLength</code> variable.",
"For example, if we created a variable <code>var firstName = \"Julie\"</code>, we could find out how long the string \"Julie\" is by using the <code>firstName.length</code> property." "For example, if we created a variable <code>var firstName = \"Charles\"</code>, we could find out how long the string \"Charles\" is by using the <code>firstName.length</code> property."
], ],
"tests": [ "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(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 <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>');" "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 <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>')"
], ],
"challengeSeed": [ "challengeSeed": [
"var firstNameLength = 0;", "var firstNameLength = 0;",
"var lastNameLength = 0;", "var lastNameLength = 0;",
"var firstName = \"Madeline\";", "var firstName = \"Ada\";",
"", "",
"firstNameLength = firstName.length;", "firstNameLength = firstName.length;",
"", "",
"var lastName = \"Chen\";", "var lastName = \"Lovelace\";",
"", "",
"lastNameLength = lastName;", "lastNameLength = lastName;",
"", "",
@ -146,24 +145,24 @@
"title": "Use Bracket Notation to Find the First Character in a String", "title": "Use Bracket Notation to Find the First Character in a String",
"difficulty": "9.9810", "difficulty": "9.9810",
"description": [ "description": [
"Use <code>bracket notation</code> to find the first character in a the <code>firstLetterOfLastName</code> variable.",
"<code>Bracket notation</code> is a way to get a character at a specific <code>index</code> within a string.", "<code>Bracket notation</code> is a way to get a character at a specific <code>index</code> within a string.",
"Computers don't start counting at 1 like humans do. They start at 0.", "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 <code>var firstName = \"Julie\"</code>, you can get the value of the first letter of the string by using <code>firstName[0]</code>.", "For example, the character at index 0 in the word \"Charles\" is \"C\". So if <code>var firstName = \"Charles\"</code>, you can get the value of the first letter of the string by using <code>firstName[0]</code>.",
"Use <code>bracket notation</code> to find the first character in a the <code>firstLetterOfLastName</code> variable.",
"Try looking at the <code>firstLetterOfFirstName</code> variable declaration if you get stuck." "Try looking at the <code>firstLetterOfFirstName</code> variable declaration if you get stuck."
], ],
"tests": [ "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": [ "challengeSeed": [
"var firstLetterOfLastName = \"\"", "var firstLetterOfLastName = \"\"",
"var firstLetterOfLastName = \"\"", "var firstLetterOfLastName = \"\"",
"", "",
"var firstName = \"Madeline\";", "var firstName = \"Ada\";",
"", "",
"firstLetterOfFirstName = firstName[0];", "firstLetterOfFirstName = firstName[0];",
"", "",
"var lastName = \"Chen\";", "var lastName = \"Lovelace\";",
"", "",
"firstLetterOfLastName = lastName;", "firstLetterOfLastName = lastName;",
"", "",
@ -181,20 +180,20 @@
"title": "Use Bracket Notation to Find the Nth Character in a String", "title": "Use Bracket Notation to Find the Nth Character in a String",
"difficulty": "9.9811", "difficulty": "9.9811",
"description": [ "description": [
"Just like the last lesson where we used <code>Bracket Notation</code>to access the first letter we can use the same method to get the letters ar other positions", "You can also use <code>bracket Notation</code>to get the character at other positions within a string.",
"Don't forget that computers start counting at 0 so the first letter is actually the zeroth one", "Remember that computers start counting at 0, so the first character is actually the zeroth character.",
"Let's now try to set <code>thirdLetterOfLastName</code>to equal the <code>third letter</code> of the <code>lastName</code>variable", "Let's try to set <code>thirdLetterOfLastName</code>to equal the <code>third letter</code> of the <code>lastName</code> variable.",
"Try looking at the <code>secondLetterOfFirstName</code> variable declaration if you get stuck." "Try looking at the <code>secondLetterOfFirstName</code> variable declaration if you get stuck."
], ],
"tests": [ "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": [ "challengeSeed": [
"var firstName = \"Madeline\";", "var firstName = \"Ada\";",
"", "",
"var secondLetterOfFirstName = firstName[1];", "var secondLetterOfFirstName = firstName[1];",
"", "",
"var lastName = \"Chen\";", "var lastName = \"Lovelace\";",
"", "",
"var thirdLetterOfLastName = lastName;", "var thirdLetterOfLastName = lastName;",
"", "",
@ -212,22 +211,21 @@
"title": "Use Bracket Notation to Find the Last Character in a String", "title": "Use Bracket Notation to Find the Last Character in a String",
"difficulty": "9.9812", "difficulty": "9.9812",
"description": [ "description": [
"Use <code>bracket notation</code> to find the last character in the <code>lastName</code> variable.",
"For example, the character at index 0 in the word \"Julie\" is \"J\". So if <code>var firstName = \"Julie\"</code>, you can get the value of the first letter of the string by using <code>firstName[0]</code>.",
"In order to get the last letter of a string, you can subtract one from the string's length.", "In order to get the last letter of a string, you can subtract one from the string's length.",
"For example, if <code>var firstName = \"Julie\"</code>, you can get the value of the last letter of the string by using <code>firstName[firstName.length - 1]</code>.", "For example, if <code>var firstName = \"Charles\"</code>, you can get the value of the last letter of the string by using <code>firstName[firstName.length - 1]</code>.",
"Use <code>bracket notation</code> to find the last character in the <code>lastName</code> variable.",
"Try looking at the <code>lastLetterOfLastName</code> variable declaration if you get stuck." "Try looking at the <code>lastLetterOfLastName</code> variable declaration if you get stuck."
], ],
"tests": [ "tests": [
"assert(lastLetterOfLastName == \"n\", 'lastLetterOfLastName should be <code>n</code>');", "assert(lastLetterOfLastName === \"e\", 'lastLetterOfLastName should be \"e\"')",
"assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the last letter');" "assert(editor.getValue().match(/\\.length/g), 'You have to use <code>.length</code> to get the last letter')"
], ],
"challengeSeed": [ "challengeSeed": [
"var firstName = \"Madeline\";", "var firstName = \"Ada\";",
"", "",
"var lastLetterOfFirstName = firstName[firstName.length - 1];", "var lastLetterOfFirstName = firstName[firstName.length - 1];",
"", "",
"var lastName = \"Chen\";", "var lastName = \"Lovelace\";",
"", "",
"var lastLetterOfLastName = lastName;", "var lastLetterOfLastName = lastName;",
"", "",
@ -245,22 +243,21 @@
"title": "Use Bracket Notation to Find the Nth-to-Last Character in a String", "title": "Use Bracket Notation to Find the Nth-to-Last Character in a String",
"difficulty": "9.9813", "difficulty": "9.9813",
"description": [ "description": [
"Use <code>bracket notation</code> to find the second-to-last character in the <code>lastName</code> variable.",
"For example, the character at index 0 in the word \"Julie\" is \"J\". So if <code>var firstName = \"Julie\"</code>, you can get the value of the first letter of the string by using <code>firstName[0]</code>.",
"In order to get the last letter of a string, you can subtract one from the string's length.", "In order to get the last letter of a string, you can subtract one from the string's length.",
"For example, if <code>var firstName = \"Julie\"</code>, you can get the value of the third-to-last letter of the string by using <code>firstName[firstName.length - 3]</code>.", "For example, you can get the value of the third-to-last letter of the <code>var firstName = \"Charles\"</code> string by using <code>firstName[firstName.length - 3]</code>.",
"Use <code>bracket notation</code> to find the second-to-last character in the <code>lastName</code> string.",
"Try looking at the <code>lastLetterOfLastName</code> variable declaration if you get stuck." "Try looking at the <code>lastLetterOfLastName</code> variable declaration if you get stuck."
], ],
"tests": [ "tests": [
"assert(secondToLastLetterOfLastName == \"e\", 'secondToLastLetterOfLastName should be e');", "assert(secondToLastLetterOfLastName === 'c', 'secondToLastLetterOfLastName should be \"c\".')",
"assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the third last letter');" "assert(editor.getValue().match(/\\.length/g), 'You have to use .length to get the third last letter.')"
], ],
"challengeSeed": [ "challengeSeed": [
"var firstName = \"Madeline\";", "var firstName = \"Ada\";",
"", "",
"var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];", "var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];",
"", "",
"var lastName = \"Chen\";", "var lastName = \"Lovelace\";",
"", "",
"var secondToLastLetterOfLastName = lastName;", "var secondToLastLetterOfLastName = lastName;",
"", "",
@ -278,23 +275,20 @@
"title": "Add Two Numbers with JavaScript", "title": "Add Two Numbers with JavaScript",
"difficulty": "9.98141", "difficulty": "9.98141",
"description": [ "description": [
"In JavaScript whole numbers (called integers) can be easily used to perform mathematical functions.", "Let's try to add two numbers using JavaScript.",
"Let's try a few of the most commonly used ones now.", "JavaScript uses the <code>+</code> symbol for addition.",
"We use <code>+</code>for addition.", "Replace the <code>0</code> with the right number so you can get the result mentioned in the comment."
"Replace the <code>0</code>with correct number to achieve the result in the comment."
], ],
"tests": [ "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 <code>sum</code> equal 20')"
], ],
"challengeSeed": [ "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.", "// You can ignore everything below this line.",
"// We use this function to show you the value of your variable in your output box.", "// We use this function to show you the value of your variable in your output box.",
"// You'll learn about functions soon.", "// You'll learn about functions soon.",
"(function(z){return('add='+z);})(add);" "(function(z){return('sum='+z);})(sum);"
], ],
"type": "waypoint", "type": "waypoint",
"challengeType": 1 "challengeType": 1
@ -304,23 +298,20 @@
"title": "Subtract One Number from Another with JavaScript", "title": "Subtract One Number from Another with JavaScript",
"difficulty": "9.98142", "difficulty": "9.98142",
"description": [ "description": [
"In JavaScript whole numbers (called integers) can be easily used to perform mathematical functions.", "We can also subtract one number from another.",
"Let's try a few of the most commonly used ones now.", "JavaScript uses use the <code>-</code> symbol for subtraction.",
"We use <code>-</code>for subtraction.", "Replace the <code>0</code> with the right number so you can get the result mentioned in the comment."
"Replace the <code>0</code>with correct number to achieve the result in the comment."
], ],
"tests": [ "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 <code>difference</code> equal 12')"
], ],
"challengeSeed": [ "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.", "// You can ignore everything below this line.",
"// We use this function to show you the value of your variable in your output box.", "// We use this function to show you the value of your variable in your output box.",
"// You'll learn about functions soon.", "// You'll learn about functions soon.",
"(function(z){return('subtract='+z);})(subtract);" "(function(z){return('difference='+z);})(difference);"
], ],
"type": "waypoint", "type": "waypoint",
"challengeType": 1 "challengeType": 1
@ -330,23 +321,20 @@
"title": "Multiply Two Numbers with JavaScript", "title": "Multiply Two Numbers with JavaScript",
"difficulty": "9.98143", "difficulty": "9.98143",
"description": [ "description": [
"In JavaScript whole numbers (called integers) can be easily used to perform mathematical functions.", "We can also multiply one number by another.",
"Let's try a few of the most commonly used ones now.", "JavaScript uses use the <code>*</code> symbol for multiplication.",
"We use <code>*</code>for multiplication.", "Replace the <code>0</code> with the right number so you can get the result mentioned in the comment."
"Replace the <code>0</code>with correct number to achieve the result in the comment."
], ],
"tests": [ "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 <code>product</code> equal 80.')"
], ],
"challengeSeed": [ "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.", "// You can ignore everything below this line.",
"// We use this function to show you the value of your variable in your output box.", "// We use this function to show you the value of your variable in your output box.",
"// You'll learn about functions soon.", "// You'll learn about functions soon.",
"(function(z){return('multiply='+z);})(multiply);" "(function(z){return('product='+z);})(product)"
], ],
"type": "waypoint", "type": "waypoint",
"challengeType": 1 "challengeType": 1
@ -356,23 +344,20 @@
"title": "Divide One Number by Another with JavaScript", "title": "Divide One Number by Another with JavaScript",
"difficulty": "9.9814", "difficulty": "9.9814",
"description": [ "description": [
"In JavaScript whole numbers (called integers) can be easily used to perform mathematical functions.", "We can also divide one number by another.",
"Let's try a few of the most commonly used ones now.", "JavaScript uses use the <code>/</code> symbol for division.",
"We use <code>/</code>for division.", "Replace the <code>0</code> with the right number so you can get the result mentioned in the comment."
"Replace the <code>0</code>with correct number to achieve the result in the comment."
], ],
"tests": [ "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 <code>quotient</code> equal 2.)"
], ],
"challengeSeed": [ "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.", "// You can ignore everything below this line.",
"// We use this function to show you the value of your variable in your output box.", "// We use this function to show you the value of your variable in your output box.",
"// You'll learn about functions soon.", "// You'll learn about functions soon.",
"(function(z){return('divide='+z);})(divide);" "(function(z){return('quotient='+z);})(quotient);"
], ],
"type": "waypoint", "type": "waypoint",
"challengeType": 1 "challengeType": 1
@ -382,16 +367,15 @@
"title": "Create Decimal Numbers with JavaScript", "title": "Create Decimal Numbers with JavaScript",
"difficulty": "9.9815", "difficulty": "9.9815",
"description": [ "description": [
"In JavaScript we can work with decimal numbers.", "JavaScript number variables can also have decimals.",
"Let's create a variable <code>myDecimal</code> and give it a decimal value." "Let's create a variable <code>myDecimal</code> and give it a decimal value."
], ],
"tests": [ "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": [ "challengeSeed": [
"//var ourDecimal = 5.7", "// var ourDecimal = 5.7",
"//Create a number with a decimal point here called myDecimal", "// Create a number with a decimal point here called myDecimal",
"",
"", "",
"", "",
"", "",
@ -411,8 +395,8 @@
"In JavaScript we can work with decimal numbers." "In JavaScript we can work with decimal numbers."
], ],
"tests": [ "tests": [
"assert(multiply == 15, 'The result of multiply should be 3.75');", "assert(multiply === 15, 'The result of multiply should be 3.75.')",
"assert(divide == 2.25, 'The result of divide should be 2.25');" "assert(divide === 2.25, 'The result of divide should be 2.25.')"
], ],
"challengeSeed": [ "challengeSeed": [
"var multiply = 3.75 * 0;//equals 15", "var multiply = 3.75 * 0;//equals 15",
@ -439,9 +423,9 @@
"Refer to the example if you get stuck." "Refer to the example if you get stuck."
], ],
"tests": [ "tests": [
"assert(typeof(myArray) == \"object\", 'myArray should be an array');", "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[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[1]) !== \"undefined\" && typeof(myArray[1]) === \"number\", 'The second item in myArray should be a number')"
], ],
"challengeSeed": [ "challengeSeed": [
"//var array = [\"John\", 23];", "//var array = [\"John\", 23];",
@ -466,7 +450,7 @@
"Let's now go create a nested array called <code>myArray</code>" "Let's now go create a nested array called <code>myArray</code>"
], ],
"tests":[ "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":[ "challengeSeed":[
"var myArray = [];", "var myArray = [];",
@ -495,7 +479,7 @@
"Create a var called <code>data</code> and set it to equal the first value of <code>myArray</code>" "Create a var called <code>data</code> and set it to equal the first value of <code>myArray</code>"
], ],
"tests":[ "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":[ "challengeSeed":[
"//var ourArray = [1,2,3]", "//var ourArray = [1,2,3]",
@ -527,8 +511,8 @@
"Now Let's modify <code>myArray</code> using an index." "Now Let's modify <code>myArray</code> using an index."
], ],
"tests":[ "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(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(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":[ "challengeSeed":[
"//var ourArray = [1,2,3];", "//var ourArray = [1,2,3];",
@ -559,8 +543,8 @@
"Let's try <code>.pop()</code>now" "Let's try <code>.pop()</code>now"
], ],
"tests": [ "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] === \"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] === \"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": [ "challengeSeed": [
"//var numbers = [1,2,3];", "//var numbers = [1,2,3];",
@ -590,7 +574,7 @@
"Let's take the code we had last time and <code>push</code>this value to the end: <code>[\"dog\", 3] </code>" "Let's take the code we had last time and <code>push</code>this value to the end: <code>[\"dog\", 3] </code>"
], ],
"tests": [ "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": [ "challengeSeed": [
"var myArray = [\"John\", 23, [\"cat\", 2]];", "var myArray = [\"John\", 23, [\"cat\", 2]];",
@ -616,8 +600,8 @@
"Let's try <code>.shift()</code>now" "Let's try <code>.shift()</code>now"
], ],
"tests": [ "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[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 === \"John\" && typeof(removed) === \"string\"){return(true);}else{return(false);}})(removed), 'Removed should contain \"John\"')"
], ],
"challengeSeed": [ "challengeSeed": [
"var myArray = [\"John\", 23, [\"dog\", 3]];", "var myArray = [\"John\", 23, [\"dog\", 3]];",
@ -641,7 +625,7 @@
"Let's take the code we had last time and <code>unshift</code>this value to the end: <code>\"Paul\" </code>" "Let's take the code we had last time and <code>unshift</code>this value to the end: <code>\"Paul\" </code>"
], ],
"tests": [ "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": [ "challengeSeed": [
"var myArray = [\"John\", 23, [\"dog\", 3]];", "var myArray = [\"John\", 23, [\"dog\", 3]];",
@ -674,7 +658,7 @@
"Let's try creating and calling a function now called <code>myFunction</code>" "Let's try creating and calling a function now called <code>myFunction</code>"
], ],
"tests":[ "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":[ "challengeSeed":[
"var a = 4;", "var a = 4;",
@ -716,10 +700,10 @@
"Let's try to make an Object that represents a dog called myDog!" "Let's try to make an Object that represents a dog called myDog!"
], ],
"tests":[ "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(\"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(\"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(\"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(\"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":[ "challengeSeed":[
"//var ourDog = {", "//var ourDog = {",
@ -757,8 +741,8 @@
"" ""
], ],
"tests":[ "tests":[
"assert(myDog.bark != undefined, 'You should have added the property bark to myDog');", "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.tails === undefined, 'The property tails should have been deleted')"
], ],
"challengeSeed":[ "challengeSeed":[
"//var ourDog = {", "//var ourDog = {",
@ -807,8 +791,8 @@
"Let's try getting a for loop to work by pushing values to an array" "Let's try getting a for loop to work by pushing values to an array"
], ],
"tests":[ "tests":[
"assert(editor.getValue().match(/for\\(/g), 'You should be using a for loop for this.');", "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.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]')"
], ],
"challengeSeed":[ "challengeSeed":[
"var myArray = [];", "var myArray = [];",
@ -837,8 +821,8 @@
"Let's try getting a for loop to work by pushing values to an array" "Let's try getting a for loop to work by pushing values to an array"
], ],
"tests":[ "tests":[
"assert(editor.getValue().match(/while\\(/g), 'You should be using a while loop for this.');", "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.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]')"
], ],
"challengeSeed":[ "challengeSeed":[
"var myArray = [];", "var myArray = [];",
@ -867,8 +851,8 @@
"Let's try getting a do - while loop to work by pushing values to an array" "Let's try getting a do - while loop to work by pushing values to an array"
], ],
"tests":[ "tests":[
"assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4]');", "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((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":[ "challengeSeed":[
"var myArray = [];", "var myArray = [];",
@ -889,9 +873,9 @@
"Let's have a go of <code>Math.random()</code> now be getting <code>myFunction</code> to return a random number" "Let's have a go of <code>Math.random()</code> now be getting <code>myFunction</code> to return a random number"
], ],
"tests":[ "tests":[
"assert(typeof(myFunction()) === \"number\", 'myFunction should return a random 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((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(editor.getValue().match(/Math\\.random/g).length >= 2, 'You should be using Math.random to generate the random decimal number')"
], ],
"challengeSeed":[ "challengeSeed":[
"", "",
@ -920,10 +904,10 @@
"Let's give this technique a go now" "Let's give this technique a go now"
], ],
"tests":[ "tests":[
"assert(typeof(myFunction()) == \"number\", 'The result of myFunction should be a 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(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(!(''+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(editor.getValue().match(/Math.floor/g), 'You should use Math.floor to remove the decimal part of the number')"
], ],
"challengeSeed":[ "challengeSeed":[
"function myFunction(){", "function myFunction(){",
@ -949,9 +933,9 @@
"" ""
], ],
"tests":[ "tests":[
"assert(myFunction() >= min, 'The random number that\\'s generated by myFunction should be greater than or equal to the minimum number');", "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(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((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":[ "challengeSeed":[
" var min = 0;", " var min = 0;",
@ -986,9 +970,9 @@
"Create an if else statement to return <code>heads</code> if the flip var is zero and to return <code>tails</code> if it's not" "Create an if else statement to return <code>heads</code> if the flip var is zero and to return <code>tails</code> if it's not"
], ],
"tests":[ "tests":[
"assert((function(){if(myFunction() == \"heads\" || myFunction() == \"tails\"){return(true);}else{return(false);}})(), 'myFunction should either return heads or tails');", "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(/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(editor.getValue().match(/else/g).length >= 2, 'You should have created a new else statement')"
], ],
"challengeSeed":[ "challengeSeed":[
"function myFunction(){", "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 <code>.+</code> in the currnet RegEx with something that will find the word \"and\" and count how many times it occurs" "Let's try finding the word and in the string \"John and Alan went to the shop and got some milk\" by replacing the <code>.+</code> in the currnet RegEx with something that will find the word \"and\" and count how many times it occurs"
], ],
"tests":[ "tests":[
"assert(test==2, 'You\\'re RegEx should have found two occurances of 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\"');" "assert(editor.getValue().match(/\\/and\\+\\/gi/), 'You should have used this RegEx to find the word \"and\"')"
], ],
"challengeSeed":[ "challengeSeed":[
"var test = (function(){", "var test = (function(){",
@ -1051,8 +1035,8 @@
"<code>/\\d+/g</code>" "<code>/\\d+/g</code>"
], ],
"tests":[ "tests":[
"assert(test === 2, 'Your RegEx should have found two 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');" "assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'You should be using the following expression /\\d+/gi to find the numbers in the testString')"
], ],
"challengeSeed":[ "challengeSeed":[
"var test = (function(){", "var test = (function(){",
@ -1080,8 +1064,8 @@
"<code>/\\s+/g</code>" "<code>/\\s+/g</code>"
], ],
"tests":[ "tests":[
"assert(test === 7, 'Your RegEx should have found seven 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');" "assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'You should be using the following expression /\\s+/gi to find the spaces in the testString')"
], ],
"challengeSeed":[ "challengeSeed":[
"var test = (function(){", "var test = (function(){",
@ -1108,8 +1092,8 @@
"You can invert any match by using the uppercase version of the selector <code>\\s</code> versus <code>\\S</code> for example" "You can invert any match by using the uppercase version of the selector <code>\\s</code> versus <code>\\S</code> for example"
], ],
"tests":[ "tests":[
"assert(test === 36, 'Your RegEx should have found seven 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');" "assert(editor.getValue().match(/\\/\\\\S\\/gi/gi), 'You should be using the following expression /\\S+/gi to find the spaces in the testString')"
], ],
"challengeSeed":[ "challengeSeed":[
"var test = (function(){", "var test = (function(){",
@ -1139,10 +1123,10 @@
"<code>Math.floor(Math.random() * (5 - 1 + 1)) + 1; </code>" "<code>Math.floor(Math.random() * (5 - 1 + 1)) + 1; </code>"
], ],
"tests":[ "tests":[
"assert(typeof(runSlots($(\".slot\"))[0]) == \"number\", 'slotOne should be a random number');", "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\"))[1]) === \"number\", 'slotTwo should be a random number')",
"assert(typeof(runSlots($(\".slot\"))[2]) == \"number\", 'slotThree 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((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":[ "challengeSeed":[
"fccss", "fccss",
@ -1295,7 +1279,7 @@
"<code>}</code>" "<code>}</code>"
], ],
"tests":[ "tests":[
"assert((function(){var data = runSlots();if(data == null){return(true)}else{if(data[0] == data[1] && data[1] == data[2]){return(true);}else{return(false);}}})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return null');" "assert((function(){var data = runSlots();if(data === null){return(true)}else{if(data[0] === data[1] && data[1] === data[2]){return(true);}else{return(false);}}})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return null')"
], ],
"challengeSeed":[ "challengeSeed":[
"fccss", "fccss",
@ -1453,8 +1437,8 @@
"Use the above selector to display each number in the corresponding slot" "Use the above selector to display each number in the corresponding slot"
], ],
"tests":[ "tests":[
"assert((function(){runSlots();if($($(\".slot\")[0]).html().replace(/\\s/gi, \"\") !== \"\" && $($(\".slot\")[1]).html().replace(/\\s/gi, \"\") !== \"\" && $($(\".slot\")[2]).html().replace(/\\s/gi, \"\") !== \"\"){return(true);}else{return(false);}})(), 'You should be displaying the result of the slot numbers in the corresponding slots');", "assert((function(){runSlots();if($($(\".slot\")[0]).html().replace(/\\s/gi, \"\") !== \"\" && $($(\".slot\")[1]).html().replace(/\\s/gi, \"\") !== \"\" && $($(\".slot\")[2]).html().replace(/\\s/gi, \"\") !== \"\"){return(true);}else{return(false);}})(), 'You should be displaying the result of the slot numbers in the corresponding slots')",
"assert((function(){if(editor.match( /\\$\\(\\$\\(\\\"\\.slot\\\"\\)\\[\\d\\]\\)/gi )){if(editor.match( /\\$\\(\\$\\(\\\"\\.slot\\\"\\)\\[\\d\\]\\)/gi ).length >= 3 && editor.match( /\\.html\\(slotOne\\);/gi ) && editor.match( /\\.html\\(slotTwo\\);/gi ) && editor.match( /\\.html\\(slotThree\\);/gi )){return(true);}else{return(false);}}else{return(false);}})(), 'You should have used the the selector given in the description to select each slot and assign it the value of slotOne&#44; slotTwo and slotThree respectively');" "assert((function(){if(editor.match( /\\$\\(\\$\\(\\\"\\.slot\\\"\\)\\[\\d\\]\\)/gi )){if(editor.match( /\\$\\(\\$\\(\\\"\\.slot\\\"\\)\\[\\d\\]\\)/gi ).length >= 3 && editor.match( /\\.html\\(slotOne\\);/gi ) && editor.match( /\\.html\\(slotTwo\\);/gi ) && editor.match( /\\.html\\(slotThree\\);/gi )){return(true);}else{return(false);}}else{return(false);}})(), 'You should have used the the selector given in the description to select each slot and assign it the value of slotOne&#44; slotTwo and slotThree respectively')"
], ],
"challengeSeed":[ "challengeSeed":[
"fccss", "fccss",
@ -1616,10 +1600,10 @@
"<code>$($('.slot')[0]).html('&lt;img src = \"' + images[slotOne-1] + '\"&gt;');<code>" "<code>$($('.slot')[0]).html('&lt;img src = \"' + images[slotOne-1] + '\"&gt;');<code>"
], ],
"tests":[ "tests":[
"assert(editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi) && editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi).length >= 3, 'Use the provided code three times. One for each slot');", "assert(editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi) && editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi).length >= 3, 'Use the provided code three times. One for each slot')",
"assert(editor.match(/slotOne/gi) && editor.match(/slotOne/gi).length >= 7, 'You should have used the slotOne value at least once');", "assert(editor.match(/slotOne/gi) && editor.match(/slotOne/gi).length >= 7, 'You should have used the slotOne value at least once')",
"assert(editor.match(/slotTwo/gi) && editor.match(/slotTwo/gi).length >=8, 'You should have used the slotTwo value at least once');", "assert(editor.match(/slotTwo/gi) && editor.match(/slotTwo/gi).length >=8, 'You should have used the slotTwo value at least once')",
"assert(editor.match(/slotThree/gi) && editor.match(/slotThree/gi).length >= 7, 'You should have used the slotThree value at least once');" "assert(editor.match(/slotThree/gi) && editor.match(/slotThree/gi).length >= 7, 'You should have used the slotThree value at least once')"
], ],
"challengeSeed":[ "challengeSeed":[
"fccss", "fccss",
@ -1635,7 +1619,7 @@
" slotTwo = Math.floor(Math.random() * (5 - 1 + 1)) + 1;", " slotTwo = Math.floor(Math.random() * (5 - 1 + 1)) + 1;",
" slotThree = 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')", " $('.logger').html('Not A Win')",
" ", " ",
" /*Don't modify above this line*/", " /*Don't modify above this line*/",

View File

@ -19,9 +19,9 @@
"Before we dive into Object Oriented Programming Let's take a quick look over objects in javascript" "Before we dive into Object Oriented Programming Let's take a quick look over objects in javascript"
], ],
"tests":[ "tests":[
"assert(motorBike.wheels===2, 'You should have given motorBike two wheels');", "assert(motorBike.wheels===2, 'You should have given motorBike two wheels')",
"assert(motorBike.engine===1, 'You should have given motorBike one engine');", "assert(motorBike.engine===1, 'You should have given motorBike one engine')",
"assert(motorBike.seats===1, 'You should have given motorBike one seat');" "assert(motorBike.seats===1, 'You should have given motorBike one seat')"
], ],
"challengeSeed":[ "challengeSeed":[
"//Here is a sample Object", "//Here is a sample Object",
@ -53,8 +53,8 @@
], ],
"tests":[ "tests":[
"assert((new Car()).wheels === 4, \"myCar.wheels should be four. Make sure that you haven't changed this value\");", "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()).engine) === 'number', 'myCar.engine should be a number')",
"assert(typeof((new Car()).seats) === 'number', 'myCar.seats should be a number');" "assert(typeof((new Car()).seats) === 'number', 'myCar.seats should be a number')"
], ],
"challengeSeed":[ "challengeSeed":[
"//Let's add the properties engine and seats to the car in the same way that the property wheels has been added below. They should both be numbers", "//Let's add the properties engine and seats to the car in the same way that the property wheels has been added below. They should both be numbers",
@ -79,9 +79,9 @@
"We can also create variables and functions that aren't accessible from outside the Object" "We can also create variables and functions that aren't accessible from outside the Object"
], ],
"tests":[ "tests":[
"assert(typeof(myBike.getSpeed)!=='undefined' && typeof(myBike.getSpeed) === 'function', 'The method getSpeed of myBike should be accessible outside the Object');", "assert(typeof(myBike.getSpeed)!=='undefined' && typeof(myBike.getSpeed) === 'function', 'The method getSpeed of myBike should be accessible outside the Object')",
"assert(typeof(myBike.speed) === 'undefined', 'We should not been able');", "assert(typeof(myBike.speed) === 'undefined', 'We should not been able')",
"assert(typeof(myBike.addUnit === 'undefined'), '');" "assert(typeof(myBike.addUnit === 'undefined'), '')"
], ],
"challengeSeed":[ "challengeSeed":[
"//Let's create an object with a two functions. One attached as a property and one not.", "//Let's create an object with a two functions. One attached as a property and one not.",
@ -127,10 +127,10 @@
"The instance inherits all the properties and methods of the original Object" "The instance inherits all the properties and methods of the original Object"
], ],
"tests":[ "tests":[
"assert((new Car()).wheels === 4, 'The property wheels should be four in the object constructor');", "assert((new Car()).wheels === 4, 'The property wheels should be four in the object constructor')",
"assert(typeof((new Car()).engine) === 'undefined', 'There should not be a property engine 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(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(typeof(myCar.engine) === 'number', 'The property engine of myCar should be a number')"
], ],
"challengeSeed":[ "challengeSeed":[
"var Car = function(){", "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" "The map method is one of the easiest ways to iterate through an array or object there is. Let's use it now"
], ],
"tests":[ "tests":[
"assert.deepEqual(array, [4,5,6,7,8], 'You should have added three to each value in the array');", "assert.deepEqual(array, [4,5,6,7,8], 'You should have added three to each value in the array')",
"assert(editor.getValue().match(/\\.map\\(/gi), 'You should be making use of the map method');", "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(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\]/gi), 'You should only modify the array with .map')"
], ],
"challengeSeed":[ "challengeSeed":[
"//Use map to add three to each value in the array", "//Use map to add three to each value in the array",
@ -186,8 +186,8 @@
"}</code>" "}</code>"
], ],
"tests":[ "tests":[
"assert(singleVal == 30, 'singleVal should have been set to the result of you reduce operation');", "assert(singleVal == 30, 'singleVal should have been set to the result of you reduce operation')",
"assert(editor.getValue().match(/\\.reduce\\(/gi), 'You should have made use of the reduce method');" "assert(editor.getValue().match(/\\.reduce\\(/gi), 'You should have made use of the reduce method')"
], ],
"challengeSeed":[ "challengeSeed":[
"var array = [4,5,6,7,8];", "var array = [4,5,6,7,8];",
@ -213,8 +213,8 @@
"});</code>" "});</code>"
], ],
"tests":[ "tests":[
"assert.deepEqual(array, [1,2,3,4,5], 'You should have removed all the values from the array that are less than six');", "assert.deepEqual(array, [1,2,3,4,5], 'You should have removed all the values from the array that are less than six')",
"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(/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);" "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":[ "challengeSeed":[
@ -239,9 +239,9 @@
"" ""
], ],
"tests":[ "tests":[
"assert.deepEqual(array, ['alpha', 'beta', 'charlie'], 'You should have sorted the array alphabetically');", "assert.deepEqual(array, ['alpha', 'beta', 'charlie'], 'You should have sorted the array alphabetically')",
"assert(editor.getValue().match(/\\[\\'beta\\'\\,\\s\\'alpha\\'\\,\\s'charlie\\'\\];/gi), 'You should be sorting the array using sort');", "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(editor.getValue().match(/\\.sort\\(\\)/gi), 'You should have made use of the sort method')"
], ],
"challengeSeed":[ "challengeSeed":[
"var array = ['beta', 'alpha', 'charlie'];", "var array = ['beta', 'alpha', 'charlie'];",
@ -261,9 +261,9 @@
"You can use the reverse method to reverse the contents of an array" "You can use the reverse method to reverse the contents of an array"
], ],
"tests": [ "tests": [
"assert.deepEqual(array, [7,6,5,4,3,2,1], 'You should reverse the array');", "assert.deepEqual(array, [7,6,5,4,3,2,1], 'You should reverse the array')",
"assert(editor.getValue().match(/\\.reverse\\(\\)/gi), '');", "assert(editor.getValue().match(/\\.reverse\\(\\)/gi), '')",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\,6\\,7/gi), '');" "assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\,6\\,7/gi), '')"
], ],
"challengeSeed": [ "challengeSeed": [
"var array = [1,2,3,4,5,6,7];", "var array = [1,2,3,4,5,6,7];",
@ -284,9 +284,9 @@
"<code>array = array.concat(otherArray);</code>" "<code>array = array.concat(otherArray);</code>"
], ],
"tests": [ "tests": [
"assert.deepEqual(array, [1,2,3,4,5,6], 'You should concat the two arrays together');", "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(/\\.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(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": [ "challengeSeed": [
"var array = [1,2,3];", "var array = [1,2,3];",
@ -310,8 +310,8 @@
"<code>array = string.split(' ');</code>" "<code>array = string.split(' ');</code>"
], ],
"tests":[ "tests":[
"assert(typeof(array) === 'object' && array.length === 5, 'You should have split the string by it\\'s spaces');", "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(/\\.split\\(/gi, 'You should have made use of the split method on the string')"
], ],
"challengeSeed":[ "challengeSeed":[
"var string = \"Split me into an array\";", "var string = \"Split me into an array\";",
@ -332,8 +332,8 @@
"<code>var joinMe = joinMe.join(\" \");</code>" "<code>var joinMe = joinMe.join(\" \");</code>"
], ],
"tests":[ "tests":[
"assert(typeof(joinMe) === 'string' && joinMe === \"Split me into an array\", 'You should have joined the arrays by it\\'s spaces');", "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(/\\.join\\(/gi, 'You should have made use of the join method on the array')"
], ],
"challengeSeed":[ "challengeSeed":[
"var joinMe = [\"Split\",\"me\",\"into\",\"an\",\"array\"];", "var joinMe = [\"Split\",\"me\",\"into\",\"an\",\"array\"];",