diff --git a/challenges/basic-javascript.json b/challenges/basic-javascript.json
index fb8bcbc13f..9babb7d202 100644
--- a/challenges/basic-javascript.json
+++ b/challenges/basic-javascript.json
@@ -16,9 +16,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), '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), 'Make sure that you close the comment with a \\*\/
');"
],
"challengeSeed":[
],
@@ -35,8 +35,8 @@
"Let's modify our welcomeToBooleans
function so that it will return true
instead of false
when 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() {",
@@ -65,7 +65,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\";",
@@ -89,8 +89,8 @@
"Now let's create two new string variables: myFirstName
and 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\";",
@@ -115,8 +115,8 @@
"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 === 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
')"
+ "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;",
@@ -151,7 +151,7 @@
"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 === \"L\"){return(true);}else{return(false);}})(), 'The first letter of firstLetterOfLastName should be a L')"
+ "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 = \"\"",
@@ -185,7 +185,7 @@
"Try looking at the secondLetterOfFirstName
variable declaration if you get stuck."
],
"tests": [
- "assert(thirdLetterOfLastName === 'v', 'The third last letter of lastName should be a \"v\"')"
+ "assert(thirdLetterOfLastName === 'v', 'The third last letter of lastName should be a \"v\"');"
],
"challengeSeed": [
"var firstName = \"Ada\";",
@@ -216,8 +216,8 @@
"Try looking at the lastLetterOfLastName
variable declaration if you get stuck."
],
"tests": [
- "assert(lastLetterOfLastName === \"e\", 'lastLetterOfLastName should be \"e\"')",
- "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 = \"Ada\";",
@@ -248,8 +248,8 @@
"Try looking at the lastLetterOfLastName
variable declaration if you get stuck."
],
"tests": [
- "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(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 = \"Ada\";",
@@ -279,7 +279,7 @@
"Replace the 0
with the correct number so you can get the result mentioned in the comment."
],
"tests": [
- "assert((function(){if(sum === 20 && editor.getValue().match(/\\+/g)){return(true);}else{return(false);}})(), 'Make the variable sum
equal 20')"
+ "assert((function(){if(sum === 20 && editor.getValue().match(/\\+/g)){return(true);}else{return(false);}})(), 'Make the variable sum
equal 20');"
],
"challengeSeed": [
"var sum = 10 + 0; //make this equal to 20 by changing the 0 into the appropriate number.",
@@ -302,7 +302,7 @@
"Replace the 0
with the correct number so you can get the result mentioned in the comment."
],
"tests": [
- "assert((function(){if(difference === 12 && editor.getValue().match(/\\-/g)){return(true);}else{return(false);}})(), 'Make the variable difference
equal 12')"
+ "assert((function(){if(difference === 12 && editor.getValue().match(/\\-/g)){return(true);}else{return(false);}})(), 'Make the variable difference
equal 12');"
],
"challengeSeed": [
"var difference = 45 - 0; //make this equal to 12 by changing the 0 into the appropriate number.",
@@ -325,7 +325,7 @@
"Replace the 0
with the correct number so you can get the result mentioned in the comment."
],
"tests": [
- "assert((function(){if(product === 80 && editor.getValue().match(/\\*/g)){return(true);}else{return(false);}})(), 'Make the variable product
equal 80.')"
+ "assert((function(){if(product === 80 && editor.getValue().match(/\\*/g)){return(true);}else{return(false);}})(), 'Make the variable product
equal 80.');"
],
"challengeSeed": [
"var product = 8 * 0; //make this equal to 80 by changing the 0 into the appropriate number.",
@@ -348,7 +348,7 @@
"Replace the 0
with the correct number so you can get the result mentioned in the comment."
],
"tests": [
- "assert((function(){if(quotient === 2 && editor.getValue().match(/\\//g)){return(true);}else{return(false);}})(), 'Make the variable quotient
equal 2.')"
+ "assert((function(){if(quotient === 2 && editor.getValue().match(/\\//g)){return(true);}else{return(false);}})(), 'Make the variable quotient
equal 2.');"
],
"challengeSeed": [
"var quotient = 66 / 0; //make this equal to 2 by changing the 0 into the appropriate number.",
@@ -370,7 +370,7 @@
"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;",
@@ -395,7 +395,7 @@
"Replace the 0.0
with the correct number so that you get the result mentioned in the comments."
],
"tests": [
- "assert((function(){if(product === 5.0 && editor.getValue().match(/\\*/g)){return(true);}else{return(false);}})(), 'Make the variable product
equal 5.0.')"
+ "assert((function(){if(product === 5.0 && editor.getValue().match(/\\*/g)){return(true);}else{return(false);}})(), 'Make the variable product
equal 5.0.');"
],
"challengeSeed": [
"var quotient = 4.4 / 2.0; // equals 2.2",
@@ -663,7 +663,7 @@
"Create and call a function 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;",
@@ -709,10 +709,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 = {",
@@ -749,8 +749,8 @@
"Let's add the property \"bark\", and delete the property \"tails\"."
],
"tests":[
- "assert(myDog.bark !== undefined, 'Add the property \"bark\" to myDog.')",
- "assert(myDog.tails === undefined, 'Delete the property \"tails\" from myDog.')"
+ "assert(myDog.bark !== undefined, 'Add the property \"bark\" to myDog.');",
+ "assert(myDog.tails === undefined, 'Delete the property \"tails\" from myDog.');"
],
"challengeSeed":[
"//var ourDog = {",
@@ -797,8 +797,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 = [];",
@@ -825,8 +825,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 = [];",
@@ -847,9 +847,9 @@
"Use Math.random()
to get 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":[
"",
@@ -878,10 +878,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(){",
@@ -906,9 +906,9 @@
"By using this we can control the output of the random number."
],
"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;",
@@ -943,9 +943,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(){",
@@ -978,8 +978,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() {",
@@ -1008,8 +1008,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() {",
@@ -1037,8 +1037,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(){",
@@ -1065,8 +1065,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(){",
@@ -1096,10 +1096,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",
@@ -1252,7 +1252,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",
@@ -1410,8 +1410,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",
@@ -1573,10 +1573,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",
@@ -1592,8 +1592,8 @@
" slotTwo = Math.floor(Math.random() * (5 - 1 + 1)) + 1;",
" slotThree = Math.floor(Math.random() * (5 - 1 + 1)) + 1;",
" ",
- " $('.logger').html('')",
- " $('.logger').html('Not A Win')",
+ " $('.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 0d815b3635..c7334bf9d7 100644
--- a/challenges/object-oriented-and-functional-programming.json
+++ b/challenges/object-oriented-and-functional-programming.json
@@ -15,13 +15,12 @@
"title":"Waypoint: A Review On Objects",
"difficulty":0,
"description":[
- "",
"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",
@@ -48,13 +47,12 @@
"title":"Waypoint: Constructing Objects",
"difficulty":0,
"description":[
- "",
"We are also able to create Objects using functions"
],
"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",
@@ -74,14 +72,13 @@
"title":"Waypoint: Understanding Public and Private Properties",
"difficulty":0,
"description":[
- "",
"In the last challenge we use the this
to reference public properties the current object or function.",
"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.",
@@ -122,15 +119,14 @@
"title":"Waypoint: Instantiation",
"difficulty":0,
"description":[
- "",
"Instantiation at it's most basic level is where you are creating a copy of an object from a template for use at a later time",
"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(){",
@@ -151,7 +147,6 @@
"title":"Waypoint: Using .map",
"difficulty":0,
"description":[
- "",
"array = array.map(function(val){",
" return(val+1);",
"});
",
@@ -159,9 +154,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",
@@ -178,20 +173,17 @@
"title":"Waypoint: Using .reduce",
"difficulty":0,
"description":[
- "",
"Reduce can be useful for condensing and array or numbers into one value.",
- "",
"var singleVal = array.reduce(function(previousVal, currentVal){",
" return(previousVal+currentVal);",
"}
"
],
"tests":[
- "assert(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];",
- "",
"var singleVal = 0;",
"",
"",
@@ -213,8 +205,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":[
@@ -231,17 +223,15 @@
"title":"Waypoint: Using .sort",
"difficulty":0,
"description":[
- "",
"You can use the method sort to easily sort the values in the array alphabetically or numerically",
"var array = [1,3,2];",
"array = array.sort();
",
- "This will return [1, 2, 3]",
- ""
+ "This will return [1, 2, 3]"
],
"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'];",
@@ -257,13 +247,12 @@
"title": "Waypoint: Using .reverse",
"difficulty": 0,
"description": [
- "",
"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];",
@@ -279,14 +268,13 @@
"title": "Waypoint: Using .concat",
"difficulty": 0,
"description": [
- "",
"Concat can be used to merge the contents of two arrays into one",
"array = array.concat(otherArray);
"
],
"tests": [
- "assert.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 +298,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\";",
@@ -327,13 +315,12 @@
"title":"Waypoint: Using .join",
"difficulty":0,
"description":[
- "",
"We can use the join method to join each element in an array into a string separated by whatever delimiter you provide as an argument to the join operation",
"var joinMe = joinMe.join(\" \");
"
],
"tests":[
- "assert(typeof(joinMe) === 'string' && joinMe === \"Split me into an array\", 'You should have joined the arrays by it\\'s spaces')",
- "assert(/\\.join\\(/gi, 'You should have made use of the join method on the array')"
+ "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\"];",