diff --git a/seed/challenges/01-front-end-development-certification/basic-javascript.json b/seed/challenges/01-front-end-development-certification/basic-javascript.json
index ce5437833d..bba37ad339 100644
--- a/seed/challenges/01-front-end-development-certification/basic-javascript.json
+++ b/seed/challenges/01-front-end-development-certification/basic-javascript.json
@@ -20,9 +20,9 @@
" "
],
"tests": [
- "assert(editor.getValue().match(/(\\/\\/)...../g), 'message: Create a //
style comment that contains at least five letters.');",
- "assert(editor.getValue().match(/(\\/\\*)[\\w\\W]{5,}(?=\\*\\/)/gm), 'message: Create a /* */
style comment that contains at least five letters.');",
- "assert(editor.getValue().match(/(\\*\\/)/g), 'message: Make sure that you close the comment with a */
.');"
+ "assert(code.match(/(\\/\\/)...../g), 'message: Create a //
style comment that contains at least five letters.');",
+ "assert(code.match(/(\\/\\*)[\\w\\W]{5,}(?=\\*\\/)/gm), 'message: Create a /* */
style comment that contains at least five letters.');",
+ "assert(code.match(/(\\*\\/)/g), 'message: Make sure that you close the comment with a */
.');"
],
"type": "waypoint",
"challengeType": "1"
@@ -103,10 +103,10 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(/var a;/.test(editor.getValue()) && /var b = 2;/.test(editor.getValue()), 'message: Do not change code above the line');",
+ "assert(/var a;/.test(code) && /var b = 2;/.test(code), 'message: Do not change code above the line');",
"assert(typeof a === 'number' && a === 7, 'message: a
should have a value of 7');",
"assert(typeof b === 'number' && b === 7, 'message: b
should have a value of 7');",
- "assert(editor.getValue().match(/b\\s*=\\s*a\\s*;/g), 'message: a
should be assigned to b
with =
');"
+ "assert(code.match(/b\\s*=\\s*a\\s*;/g), 'message: a
should be assigned to b
with =
');"
],
"challengeSeed": [
"// Setup",
@@ -147,7 +147,7 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(/var\\s+a\\s*=\\s*9\\s*/.test(editor.getValue()), 'message: Initialize a
to a value of 9
');"
+ "assert(/var\\s+a\\s*=\\s*9\\s*/.test(code), 'message: Initialize a
to a value of 9
');"
],
"challengeSeed": [
"// Example",
@@ -183,7 +183,7 @@
"assert(typeof a === 'number' && a === 6, 'message: a
should be defined and have a value of 6
');",
"assert(typeof b === 'number' && b === 15, 'message: b
should be defined and have a value of 15
');",
"assert(!/undefined/.test(c) && c === \"I am a String!\", 'message: c
should not contain undefined
and should have a value of \"I am a String!\"');",
- "assert(/a = a \\+ 1;/.test(editor.getValue()) && /b = b \\+ 5;/.test(editor.getValue()) && /c = c \\+ \" String!\";/.test(editor.getValue()), 'message: Do not change code below the line');"
+ "assert(/a = a \\+ 1;/.test(code) && /b = b \\+ 5;/.test(code) && /c = c \\+ \" String!\";/.test(code), 'message: Do not change code below the line');"
],
"challengeSeed": [
"// Initialize these three variables",
@@ -282,7 +282,7 @@
],
"tests": [
"assert(sum === 20, 'message: sum
should equal 20
');",
- "assert(/\\+/.test(editor.getValue()), 'message: Use the +
operator');"
+ "assert(/\\+/.test(code), 'message: Use the +
operator');"
],
"challengeSeed": [
"var sum = 10 + 0;",
@@ -309,7 +309,7 @@
],
"tests": [
"assert(difference === 12, 'message: Make the variable difference
equal 12.');",
- "assert(/\\d+\\s*-\\s*\\d+/.test(editor.getValue()),'message: User the -
operator');"
+ "assert(/\\d+\\s*-\\s*\\d+/.test(code),'message: User the -
operator');"
],
"challengeSeed": [
"var difference = 45 - 0;",
@@ -340,7 +340,7 @@
],
"tests": [
"assert(product === 80,'message: Make the variable product
equal 80');",
- "assert(/\\*/.test(editor.getValue()), 'message: Use the *
operator');"
+ "assert(/\\*/.test(code), 'message: Use the *
operator');"
],
"challengeSeed": [
"var product = 8 * 0;",
@@ -371,7 +371,7 @@
],
"tests": [
"assert(quotient === 2, 'message: Make the variable quotient
equal to 2.');",
- "assert(/\\d+\\s*\\/\\s*\\d+/.test(editor.getValue()), 'message: Use the /
operator');"
+ "assert(/\\d+\\s*\\/\\s*\\d+/.test(code), 'message: Use the /
operator');"
],
"challengeSeed": [
"var quotient = 66 / 0;",
@@ -398,8 +398,8 @@
"releasedOn": "January 1, 2016",
"tests": [
"assert(myVar === 88, 'message: myVar
should equal 88
');",
- "assert(/[+]{2}/.test(editor.getValue()), 'message: Use the ++
operator');",
- "assert(/var myVar = 87;/.test(editor.getValue()), 'message: Do not change code above the line');"
+ "assert(/[+]{2}/.test(code), 'message: Use the ++
operator');",
+ "assert(/var myVar = 87;/.test(code), 'message: Do not change code above the line');"
],
"challengeSeed": [
"var myVar = 87;",
@@ -437,8 +437,8 @@
"releasedOn": "January 1, 2016",
"tests": [
"assert(myVar === 10, 'message: myVar
should equal 10
');",
- "assert(/myVar[-]{2}/.test(editor.getValue()), 'message: Use the --
operator on myVar
');",
- "assert(/var myVar = 11;/.test(editor.getValue()), 'message: Do not change code above the line');"
+ "assert(/myVar[-]{2}/.test(code), 'message: Use the --
operator on myVar
');",
+ "assert(/var myVar = 11;/.test(code), 'message: Do not change code above the line');"
],
"challengeSeed": [
"var myVar = 11;",
@@ -474,7 +474,7 @@
],
"tests": [
"assert(typeof myDecimal === \"number\", 'message: myDecimal
should be a number.');",
- "assert(editor.getValue().match(/\\d+\\.\\d+/g).length >= 2, 'message: myDecimal
should have a decimal point'); "
+ "assert(code.match(/\\d+\\.\\d+/g).length >= 2, 'message: myDecimal
should have a decimal point'); "
],
"challengeSeed": [
"var ourDecimal = 5.7;",
@@ -500,7 +500,7 @@
],
"tests": [
"assert(product === 5.0, 'message: The variable product
should equal 5.0
.');",
- "assert(/\\*/.test(editor.getValue()), 'message: You should use the *
operator');"
+ "assert(/\\*/.test(code), 'message: You should use the *
operator');"
],
"tail": [
"(function(y){return 'product = '+y;})(product);"
@@ -523,7 +523,7 @@
],
"tests": [
"assert(quotient === 2.2, 'message: The variable quotient
should equal 2.2
.');",
- "assert(/\\//.test(editor.getValue()), 'message: You should use the /
operator');"
+ "assert(/\\//.test(code), 'message: You should use the /
operator');"
],
"challengeSeed": [
"var quotient = 0.0 / 2.0;",
@@ -544,7 +544,7 @@
"Example",
"
5 % 2 = 1 because", "Usage", - "In mathematics, a number can be checked even or odd by checking the remainder of division of the number by
Math.floor(5 / 2) = 2 (Quotient)
2 * 2 = 4
5 - 4 = 1 (Remainder)
2
. ",
+ "In mathematics, a number can be checked even or odd by checking the remainder of the division of the number by 2
. ",
"17 % 2 = 1 (17 is Odd)", "Note", "The remainder operator is sometimes incorrectly refered to as the \"modulus\" operator. It is very similar to modulus, but does not work properly with negative numbers.", @@ -554,7 +554,7 @@ "releasedOn": "January 1, 2016", "tests": [ "assert(remainder === 2, 'message: The value of
48 % 2 = 0 (48 is Even)
remainder
should be 2
');",
- "assert(/\\d+\\s*%\\s*\\d+/.test(editor.getValue()), 'message: You should use the %
operator');"
+ "assert(/\\d+\\s*%\\s*\\d+/.test(code), 'message: You should use the %
operator');"
],
"challengeSeed": [
"// Only change code below this line",
@@ -593,8 +593,8 @@
"assert(a === 15, 'message: a
should equal 15
');",
"assert(b === 26, 'message: b
should equal 26
');",
"assert(c === 19, 'message: c
should equal 19
');",
- "assert(editor.getValue().match(/\\+=/g).length === 3, 'message: You should use the +=
operator for each variable');",
- "assert(/var a = 3;/.test(editor.getValue()) && /var b = 17;/.test(editor.getValue()) && /var c = 12;/.test(editor.getValue()), 'message: Do not modify the code above the line');"
+ "assert(code.match(/\\+=/g).length === 3, 'message: You should use the +=
operator for each variable');",
+ "assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code), 'message: Do not modify the code above the line');"
],
"challengeSeed": [
"var a = 3;",
@@ -644,8 +644,8 @@
"assert(a === 5, 'message: a
should equal 5
');",
"assert(b === -6, 'message: b
should equal -6
');",
"assert(c === 2, 'message: c
should equal 2
');",
- "assert(editor.getValue().match(/-=/g).length === 3, 'message: You should use the -=
operator for each variable');",
- "assert(/var a = 11;/.test(editor.getValue()) && /var b = 9;/.test(editor.getValue()) && /var c = 3;/.test(editor.getValue()), 'message: Do not modify the code above the line');"
+ "assert(code.match(/-=/g).length === 3, 'message: You should use the -=
operator for each variable');",
+ "assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code), 'message: Do not modify the code above the line');"
],
"challengeSeed": [
"var a = 11;",
@@ -698,8 +698,8 @@
"assert(a === 25, 'message: a
should equal 25
');",
"assert(b === 36, 'message: b
should equal 36
');",
"assert(c === 46, 'message: c
should equal 46
');",
- "assert(editor.getValue().match(/\\*=/g).length === 3, 'message: You should use the *=
operator for each variable');",
- "assert(/var a = 5;/.test(editor.getValue()) && /var b = 12;/.test(editor.getValue()) && /var c = 4\\.6;/.test(editor.getValue()), 'message: Do not modify the code above the line');"
+ "assert(code.match(/\\*=/g).length === 3, 'message: You should use the *=
operator for each variable');",
+ "assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\\.6;/.test(code), 'message: Do not modify the code above the line');"
],
"challengeSeed": [
"var a = 5;",
@@ -750,8 +750,8 @@
"assert(a === 4, 'message: a
should equal 4
');",
"assert(b === 27, 'message: b
should equal 27
');",
"assert(c === 3, 'message: c
should equal 3
');",
- "assert(editor.getValue().match(/\\/=/g).length === 3, 'message: You should use the /=
operator for each variable');",
- "assert(/var a = 48;/.test(editor.getValue()) && /var b = 108;/.test(editor.getValue()) && /var c = 33;/.test(editor.getValue()), 'message: Do not modify the code above the line');"
+ "assert(code.match(/\\/=/g).length === 3, 'message: You should use the /=
operator for each variable');",
+ "assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code), 'message: Do not modify the code above the line');"
],
"challengeSeed": [
"var a = 48;",
@@ -884,7 +884,7 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(editor.getValue().match(/\\\\\"/g).length === 4 && editor.getValue().match(/[^\\\\]\"/g).length === 2, 'message: You should use two double quotes ("
) and four escaped double quotes (\"
) ');"
+ "assert(code.match(/\\\\\"/g).length === 4 && code.match(/[^\\\\]\"/g).length === 2, 'message: You should use two double quotes ("
) and four escaped double quotes (\"
) ');"
],
"challengeSeed": [
"var myStr; // Change this line",
@@ -915,8 +915,8 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(!/\\\\/g.test(editor.getValue()), 'message: Remove all the backslashes
(\\
)');",
- "assert(editor.getValue().match(/\"/g).length === 4 && editor.getValue().match(/'/g).length === 2, 'message: You should have two single quotes '
and four double quotes "
');",
+ "assert(!/\\\\/g.test(code), 'message: Remove all the backslashes
(\\
)');",
+ "assert(code.match(/\"/g).length === 4 && code.match(/'/g).length === 2, 'message: You should have two single quotes '
and four double quotes "
');",
"assert(myStr === 'Link', 'message: Only remove the backslashes \\
used to escape quotes.');"
],
"challengeSeed": [
@@ -972,18 +972,16 @@
"id": "56533eb9ac21ba0edf2244b7",
"title": "Concatenating Strings with Plus Operator",
"description": [
- "In JavaScript, the +
operator when used with a String
value, it is called a concatenation operator. You can build a string out of other strings by concatenating them together.",
- "",
- "'My name is Alan.' + ' And I am able to concatenate.'
",
- "",
+ "In JavaScript, when the +
operator is used with a String
value, it is called the concatenation operator. You can build a new string out of other strings by concatenating them together.",
+ "Example",
+ "'My name is Alan,' + ' I concatenate.'", "
myStr
from the strings \"This is the start. \"
and \"This is the end.\"
using the +
operator.",
- ""
+ "Build myStr
from the strings \"This is the start. \"
and \"This is the end.\"
using the +
operator."
],
"releasedOn": "January 1, 2016",
"tests": [
"assert(myStr === \"This is the start. This is the end.\", 'message: myStr
should have a value of This is the start. This is the end.
');",
- "assert(editor.getValue().match(/\"\\s*\\+\\s*\"/g).length > 1, 'message: Use the +
operator to build myStr
');"
+ "assert(code.match(/\"\\s*\\+\\s*\"/g).length > 1, 'message: Use the +
operator to build myStr
');"
],
"challengeSeed": [
"// Example",
@@ -1012,12 +1010,12 @@
"description": [
"We can also use the +=
operator to concatenate a string onto the end of an existing string variable. This can be very helpful to break a long string over several lines.",
"myStr
over several lines by concatenating these two strings:\"This is the first line. \"
and \"This is the second line.\"
using the +=
operator."
+ "Build myStr
over several lines by concatenating these two strings:\"This is the first sentance. \"
and \"This is the second sentance.\"
using the +=
operator."
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(myStr === \"This is the first line. This is the second line.\", 'message: myStr
should have a value of This is the first line. This is the second line.
');",
- "assert(editor.getValue().match(/\\w\\s*\\+=\\s*\"/g).length > 1 && editor.getValue().match(/\\w\\s*\\=\\s*\"/g).length > 1, 'message: Use the +=
operator to build myStr
');"
+ "assert(myStr === \"This is the first sentance. This is the second sentance.\", 'message: myStr
should have a value of This is the first sentance. This is the second sentance.
');",
+ "assert(code.match(/\\w\\s*\\+=\\s*\"/g).length > 1 && code.match(/\\w\\s*\\=\\s*\"/g).length > 1, 'message: Use the +=
operator to build myStr
');"
],
"challengeSeed": [
"// Example",
@@ -1031,8 +1029,8 @@
""
],
"solutions": [
- "var myStr = \"This is the first line. \";",
- "myStr += \"This is the second line.\";"
+ "var myStr = \"This is the first sentance. \";",
+ "myStr += \"This is the second sentance.\";"
],
"type": "waypoint",
"challengeType": "1",
@@ -1053,7 +1051,7 @@
"releasedOn": "January 1, 2016",
"tests": [
"assert(typeof myName !== 'undefined' && myName.length > 2, 'message: myName
should be set to a string at least 3 characters long');",
- "assert(editor.getValue().match(/\"\\s*\\+\\s*myName\\s*\\+\\s*\"/g).length > 0, 'message: Use two +
operators to build myStr
with myName inside it');"
+ "assert(code.match(/\"\\s*\\+\\s*myName\\s*\\+\\s*\"/g).length > 0, 'message: Use two +
operators to build myStr
with myName inside it');"
],
"challengeSeed": [
"// Example",
@@ -1089,7 +1087,7 @@
"releasedOn": "January 1, 2016",
"tests": [
"assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2, 'message: someAdjective
should be set to a string at least 3 characters long');",
- "assert(editor.getValue().match(/\\w\\s*\\+=\\s*someAdjective\\s*;/).length > 0, 'message: Append someAdjective
to myStr
using the +=
operator');"
+ "assert(code.match(/\\w\\s*\\+=\\s*someAdjective\\s*;/).length > 0, 'message: Append someAdjective
to myStr
using the +=
operator');"
],
"challengeSeed": [
"// Example",
@@ -1132,7 +1130,7 @@
],
"tests": [
"assert((function(){if(typeof(lastNameLength) !== \"undefined\" && typeof(lastNameLength) === \"number\" && lastNameLength === 8){return true;}else{return false;}})(), 'message: 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;}})(), 'message: You should be getting the length of lastName
by using .length
like this: lastName.length
.');"
+ "assert((function(){if(code.match(/\\.length/gi) && code.match(/\\.length/gi).length >= 2 && code.match(/var lastNameLength \\= 0;/gi) && code.match(/var lastNameLength \\= 0;/gi).length >= 1){return true;}else{return false;}})(), 'message: You should be getting the length of lastName
by using .length
like this: lastName.length
.');"
],
"challengeSeed": [
"// Example",
@@ -1171,7 +1169,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;}})(), 'message: The firstLetterOfLastName
variable should have the value of L
.');"
+ "assert((function(){if(typeof(firstLetterOfLastName) !== \"undefined\" && code.match(/\\[0\\]/gi) && typeof(firstLetterOfLastName) === \"string\" && firstLetterOfLastName === \"L\"){return true;}else{return false;}})(), 'message: The firstLetterOfLastName
variable should have the value of L
.');"
],
"challengeSeed": [
"// Example",
@@ -1216,7 +1214,7 @@
"releasedOn": "January 1, 2016",
"tests": [
"assert(myStr === \"Hello World\", 'message: myStr
should have a value of Hello World
');",
- "assert(/myStr = \"Jello World\"/.test(editor.getValue()), 'message: Do not change the code above the line');"
+ "assert(/myStr = \"Jello World\"/.test(code), 'message: Do not change the code above the line');"
],
"tail": [
"(function(v){return \"myStr = \" + v;})(myStr);"
@@ -1293,7 +1291,7 @@
],
"tests": [
"assert(lastLetterOfLastName === \"e\", 'message: lastLetterOfLastName
should be \"e\".');",
- "assert(editor.getValue().match(/\\.length/g).length === 2, 'message: You have to use .length
to get the last letter.');"
+ "assert(code.match(/\\.length/g).length === 2, 'message: You have to use .length
to get the last letter.');"
],
"challengeSeed": [
"// Example",
@@ -1331,7 +1329,7 @@
],
"tests": [
"assert(secondToLastLetterOfLastName === 'c', 'message: secondToLastLetterOfLastName
should be \"c\".');",
- "assert(editor.getValue().match(/\\.length/g).length === 2, 'message: You have to use .length
to get the second last letter.');"
+ "assert(code.match(/\\.length/g).length === 2, 'message: You have to use .length
to get the second last letter.');"
],
"challengeSeed": [
"// Example",
@@ -1513,7 +1511,7 @@
],
"tests": [
"assert((function(){if(typeof(myArray) != 'undefined' && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return true;}else{return false;}})(), 'message: myArray
should now be [3,2,3].');",
- "assert((function(){if(editor.getValue().match(/myArray\\[0\\]\\s?=\\s?/g)){return true;}else{return false;}})(), 'message: You should be using correct index to modify the value in myArray
.');"
+ "assert((function(){if(code.match(/myArray\\[0\\]\\s?=\\s?/g)){return true;}else{return false;}})(), 'message: You should be using correct index to modify the value in myArray
.');"
],
"challengeSeed": [
"// Example",
@@ -1541,7 +1539,7 @@
"id": "56592a60ddddeae28f7aa8e1",
"title": "Access Multi-Dimensional Arrays With Indexes",
"description": [
- "One way to think of a multi-dimensional array, is as an array of arrays. When you use brackets to access your array, the first set of bracket refers to the entries in the outer-most array, and each subsequent level of brackets refers to the next level of entry inside.",
+ "One way to think of a multi-dimensional array, is as an array of arrays. When you use brackets to access your array, the first set of bracket refers to the entries in the outer-most array, and each subsequent level of brackets refers to the next level of entries inside.",
"Example",
"var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3][0][1]; // equals 11
",
"Instructions
",
@@ -1550,7 +1548,7 @@
"releasedOn": "January 1, 2016",
"tests": [
"assert(myData === 8, 'message: myData
should be equal to 8
.');",
- "assert(/myArray\\[2\\]\\[1\\]/g.test(editor.getValue()), 'message: You should be using bracket notation to read the value from myArray
.');"
+ "assert(/myArray\\[2\\]\\[1\\]/g.test(code), 'message: You should be using bracket notation to read the value from myArray
.');"
],
"challengeSeed": [
"// Setup",
@@ -1801,7 +1799,7 @@
"tests": [
"assert(typeof myFunction === 'function', 'message: myFunction
should be a function');",
"assert(\"Hi World\" === logOutput, 'message: myFunction
should output \"Hi World\" to the dev console');",
- "assert(/^\\s*myFunction\\(\\)\\s*;/m.test(editor.getValue()), 'message: Call myFunction
after you define it');"
+ "assert(/^\\s*myFunction\\(\\)\\s*;/m.test(code), 'message: Call myFunction
after you define it');"
],
"challengeSeed": [
"// Example",
@@ -1851,7 +1849,8 @@
"id": "56533eb9ac21ba0edf2244bd",
"title": "Passing Values to Functions with Arguments",
"description": [
- "Functions can take input in the form of parameter. Parameters are variables that take on the value of the arguments which are passed in to the function. Here is a function with two parameters, param1
and param2
:",
+ "Functions can take input with parameters. Parameters are local variables that take on the value of the arguments which are passed into the function. ",
+ "Here is a function with two parameters, param1
and param2
:",
"function testFun(param1, param2) {
console.log(param1, param2);
}
",
"Then we can call testFun
:",
"testFun(\"Hello\", \"World\");
",
@@ -1864,7 +1863,7 @@
"assert(typeof myFunction === 'function', 'message: myFunction
should be a function');",
"capture(); myFunction(1,2); uncapture(); assert(logOutput == 3, 'message: myFunction(1,2)
should output 3
');",
"capture(); myFunction(7,9); uncapture(); assert(logOutput == 16, 'message: myFunction(7,9)
should output 16
');",
- "assert(/^\\s*myFunction\\(\\s*\\d+\\s*,\\s*\\d+\\s*\\)\\s*;/m.test(editor.getValue()), 'message: Call myFunction
after you define it');"
+ "assert(/^\\s*myFunction\\(\\s*\\d+\\s*,\\s*\\d+\\s*\\)\\s*;/m.test(code), 'message: Call myFunction
after you define it');"
],
"head": [
"var logOutput = \"\";",
@@ -1927,9 +1926,9 @@
"tests": [
"assert(typeof myGlobal != \"undefined\", 'message: myGlobal
should be defined');",
"assert(myGlobal === 10, 'message: myGlobal
should have a value of 10
');",
- "assert(/var\\s+myGlobal/.test(editor.getValue()), 'message: myGlobal
should be declared using the var
keyword');",
+ "assert(/var\\s+myGlobal/.test(code), 'message: myGlobal
should be declared using the var
keyword');",
"assert(typeof oopsGlobal != \"undefined\" && oopsGlobal === 5, 'message: oopsGlobal
should have a value of 5
');",
- "assert(!/var\\s+oopsGlobal/.test(editor.getValue()), 'message: Do not decalre oopsGlobal
using the var
keyword');"
+ "assert(!/var\\s+oopsGlobal/.test(code), 'message: Do not decalre oopsGlobal
using the var
keyword');"
],
"head": [
"var logOutput = \"\";",
@@ -2055,7 +2054,7 @@
"tests": [
"assert(outerWear === \"T-Shirt\", 'message: Do not change the value of the global outerWear
');",
"assert(myFunction() === \"sweater\", 'message: myFunction
should return \"sweater\"
');",
- "assert(/return outerWear/.test(editor.getValue()), 'message: Do not change the return statement');"
+ "assert(/return outerWear/.test(code), 'message: Do not change the return statement');"
],
"challengeSeed": [
"// Setup",
@@ -2140,12 +2139,12 @@
"var ourSum = sum(5, 12);
",
"will call sum
function, which returns a value of 17
and assigns it to ourSum
variable.",
"Instructions
",
- "Call process
function with an argument of 7
and assign it's return value to the variable processed
."
+ "Call the process
function with an argument of 7
and assign its return value to the variable processed
."
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(processed === 2, 'message: processed
should have a value of 10
');",
- "assert(/processed\\s*=\\s*process\\(\\s*7\\s*\\)\\s*;/.test(editor.getValue()), 'message: You should assign process
to processed
');"
+ "assert(processed === 2, 'message: processed
should have a value of 2
');",
+ "assert(/processed\\s*=\\s*process\\(\\s*7\\s*\\)\\s*;/.test(code), 'message: You should assign process
to processed
');"
],
"challengeSeed": [
"// Setup",
@@ -2160,7 +2159,7 @@
""
],
"tail": [
- ""
+ "(function(){return \"processed = \" + processed})();"
],
"solutions": [
"processed = process(7);"
@@ -2310,7 +2309,7 @@
"assert(myTest(10) === \"Not Equal\", 'message: myTest(10)
should return \"Not Equal\"');",
"assert(myTest(12) === \"Equal\", 'message: myTest(12)
should return \"Equal\"');",
"assert(myTest(\"12\") === \"Equal\", 'message: myTest(\"12\")
should return \"Equal\"');",
- "assert(editor.getValue().match(/val\\s*==\\s*\\d+/g).length > 0, 'message: You should use the ==
operator');"
+ "assert(code.match(/val\\s*==\\s*\\d+/g).length > 0, 'message: You should use the ==
operator');"
],
"challengeSeed": [
"// Setup",
@@ -2356,7 +2355,7 @@
"assert(myTest(10) === \"Not Equal\", 'message: myTest(10)
should return \"Not Equal\"');",
"assert(myTest(7) === \"Equal\", 'message: myTest(7)
should return \"Equal\"');",
"assert(myTest(\"7\") === \"Not Equal\", 'message: myTest(\"7\")
should return \"Not Equal\"');",
- "assert(editor.getValue().match(/val\\s*===\\s*\\d+/g).length > 0, 'message: You should use the ===
operator');"
+ "assert(code.match(/val\\s*===\\s*\\d+/g).length > 0, 'message: You should use the ===
operator');"
],
"challengeSeed": [
"// Setup",
@@ -2403,7 +2402,7 @@
"assert(myTest(12) === \"Not Equal\", 'message: myTest(12)
should return \"Not Equal\"');",
"assert(myTest(\"12\") === \"Not Equal\", 'message: myTest(\"12\")
should return \"Not Equal\"');",
"assert(myTest(\"bob\") === \"Not Equal\", 'message: myTest(\"bob\")
should return \"Not Equal\"');",
- "assert(editor.getValue().match(/val\\s*!=\\s*\\d+/g).length > 0, 'message: You should use the !=
operator');"
+ "assert(code.match(/val\\s*!=\\s*\\d+/g).length > 0, 'message: You should use the !=
operator');"
],
"challengeSeed": [
"// Setup",
@@ -2437,7 +2436,7 @@
"id": "56533eb9ac21ba0edf2244d3",
"title": "Comparison with the Strict Inequality Operator",
"description": [
- "The inequality operator (!==
) is the opposite of the strict equality operator. It means \"Strictly Not Equal\" and returns false
where strict equality would return true
and vice versa. Strict inequality will not convert data types.",
+ "The strict inequality operator (!==
) is the opposite of the strict equality operator. It means \"Strictly Not Equal\" and returns false
where strict equality would return true
and vice versa. Strict inequality will not convert data types.",
"Examples",
"3 !== 3 // false
3 !== '3' // true
4 !== 3 // true
",
"Instructions
",
@@ -2449,7 +2448,7 @@
"assert(myTest(\"17\") === \"Not Equal\", 'message: myTest(\"17\")
should return \"Not Equal\"');",
"assert(myTest(12) === \"Not Equal\", 'message: myTest(12)
should return \"Not Equal\"');",
"assert(myTest(\"bob\") === \"Not Equal\", 'message: myTest(\"bob\")
should return \"Not Equal\"');",
- "assert(editor.getValue().match(/val\\s*!==\\s*\\d+/g).length > 0, 'message: You should use the !==
operator');"
+ "assert(code.match(/val\\s*!==\\s*\\d+/g).length > 0, 'message: You should use the !==
operator');"
],
"challengeSeed": [
"// Setup",
@@ -2502,7 +2501,7 @@
"assert(myTest(99) === \"Over 10\", 'message: myTest(99)
should return \"Over 10\"');",
"assert(myTest(100) === \"Over 10\", 'message: myTest(100)
should return \"Over 10\"');",
"assert(myTest(101) === \"Over 100\", 'message: myTest(101)
should return \"Over 100\"');",
- "assert(myTest(150) === \"Over 100\", 'message: myTest(150)
should return \"Over 100\"');\nassert(editor.getValue().match(/val\\s*>\\s*\\d+/g).length > 1, 'message: You should use the >
operator at least twice');"
+ "assert(myTest(150) === \"Over 100\", 'message: myTest(150)
should return \"Over 100\"');\nassert(code.match(/val\\s*>\\s*\\d+/g).length > 1, 'message: You should use the >
operator at least twice');"
],
"challengeSeed": [
"function myTest(val) {",
@@ -2558,7 +2557,7 @@
"assert(myTest(19) === \"10 or Over\", 'message: myTest(19)
should return \"10 or Over\"');",
"assert(myTest(20) === \"20 or Over\", 'message: myTest(100)
should return \"20 or Over\"');",
"assert(myTest(21) === \"20 or Over\", 'message: myTest(101)
should return \"20 or Over\"');",
- "assert(editor.getValue().match(/val\\s*>=\\s*\\d+/g).length > 1, 'message: You should use the >=
operator at least twice');"
+ "assert(code.match(/val\\s*>=\\s*\\d+/g).length > 1, 'message: You should use the >=
operator at least twice');"
],
"challengeSeed": [
"function myTest(val) {",
@@ -2615,7 +2614,7 @@
"assert(myTest(54) === \"Under 55\", 'message: myTest(54)
should return \"Under 55\"');",
"assert(myTest(55) === \"55 or Over\", 'message: myTest(55)
should return \"55 or Over\"');",
"assert(myTest(99) === \"55 or Over\", 'message: myTest(99)
should return \"55 or Over\"');",
- "assert(editor.getValue().match(/val\\s*<\\s*\\d+/g).length > 1, 'message: You should use the <
operator at least twice');"
+ "assert(code.match(/val\\s*<\\s*\\d+/g).length > 1, 'message: You should use the <
operator at least twice');"
],
"challengeSeed": [
"function myTest(val) {",
@@ -2658,7 +2657,7 @@
"id": "56533eb9ac21ba0edf2244d7",
"title": "Comparison with the Less Than Equal To Operator",
"description": [
- "The less than equal to
operator (<=
) compares the values of two numbers. If the number to the left is less than or equl the number to the right, it returns true
. If the number on the left is greater than the number on the right, it returns false
. Like the equality operator, less than equal to
converts data types.",
+ "The less than equal to
operator (<=
) compares the values of two numbers. If the number to the left is less than or equal the number to the right, it returns true
. If the number on the left is greater than the number on the right, it returns false
. Like the equality operator, less than equal to
converts data types.",
"Examples",
" 4 <= 5 // true
'7' <= 7 // true
5 <= 5 // true
3 <= 2 // false
'8' <= 4 // false
",
"Instructions
",
@@ -2673,7 +2672,7 @@
"assert(myTest(24) === \"Smaller Than or Equal to 24\", 'message: myTest(24)
should return \"Smaller Than or Equal to 24\"');",
"assert(myTest(25) === \"25 or More\", 'message: myTest(25)
should return \"25 or More\"');",
"assert(myTest(55) === \"25 or More\", 'message: myTest(55)
should return \"25 or More\"');",
- "assert(editor.getValue().match(/val\\s*<=\\s*\\d+/g).length > 1, 'message: You should use the <=
operator at least twice');"
+ "assert(code.match(/val\\s*<=\\s*\\d+/g).length > 1, 'message: You should use the <=
operator at least twice');"
],
"challengeSeed": [
"function myTest(val) {",
@@ -2727,8 +2726,8 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(editor.getValue().match(/&&/g).length === 1, 'message: You should use the &&
operator once');",
- "assert(editor.getValue().match(/if/g).length === 1, 'message: You should only have one if
statement');",
+ "assert(code.match(/&&/g).length === 1, 'message: You should use the &&
operator once');",
+ "assert(code.match(/if/g).length === 1, 'message: You should only have one if
statement');",
"assert(myTest(0) === \"No\", 'message: myTest(0)
should return \"No\"');",
"assert(myTest(24) === \"No\", 'message: myTest(24)
should return \"No\"');",
"assert(myTest(25) === \"Yes\", 'message: myTest(25)
should return \"Yes\"');",
@@ -2775,7 +2774,7 @@
"id": "56533eb9ac21ba0edf2244d9",
"title": "Comparisons with the Logical Or Operator",
"description": [
- "The logical or operator (||
) returns true
if either ofoperands is true
. Otherwise, it returns false
.",
+ "The logical or operator (||
) returns true
if either of the operands is true
. Otherwise, it returns false
.",
"The pattern below should look familiar from prior waypoints:",
"if (num > 10) {
return \"No\";
}
if (num < 5) {
return \"No\";
}
return \"Yes\";
",
"will return \"Yes\" only if num
is between 5
and 10
(5 and 10 included). The same logic can be written as:",
@@ -2785,8 +2784,8 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(editor.getValue().match(/\\|\\|/g).length === 1, 'message: You should use the ||
operator once');",
- "assert(editor.getValue().match(/if/g).length === 1, 'message: You should only have one if
statement');",
+ "assert(code.match(/\\|\\|/g).length === 1, 'message: You should use the ||
operator once');",
+ "assert(code.match(/if/g).length === 1, 'message: You should only have one if
statement');",
"assert(myTest(0) === \"Outside\", 'message: myTest(0)
should return \"Outside\"');",
"assert(myTest(9) === \"Outside\", 'message: myTest(9)
should return \"Outside\"');",
"assert(myTest(10) === \"Inside\", 'message: myTest(10)
should return \"Inside\"');",
@@ -2842,13 +2841,13 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(editor.getValue().match(/if/g).length === 1, 'message: You should only have one if
statement');",
- "assert(/else/g.test(editor.getValue()), 'message: You should use an else
statement');",
+ "assert(code.match(/if/g).length === 1, 'message: You should only have one if
statement');",
+ "assert(/else/g.test(code), 'message: You should use an else
statement');",
"assert(myTest(4) === \"5 or Smaller\", 'message: myTest(4)
should return \"5 or Smaller\"');",
"assert(myTest(5) === \"5 or Smaller\", 'message: myTest(5)
should return \"5 or Smaller\"');",
"assert(myTest(6) === \"Bigger than 5\", 'message: myTest(6)
should return \"Bigger than 5\"');",
"assert(myTest(10) === \"Bigger than 5\", 'message: myTest(10)
should return \"Bigger than 5\"');",
- "assert(/var result = \"\";/.test(editor.getValue()) && /return result;/.test(editor.getValue()), 'message: Do not change the code above or below the lines.');"
+ "assert(/var result = \"\";/.test(code) && /return result;/.test(code), 'message: Do not change the code above or below the lines.');"
],
"challengeSeed": [
"function myTest(val) {",
@@ -2900,8 +2899,8 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(editor.getValue().match(/else/g).length > 1, 'message: You should have at least two else
statements');",
- "assert(editor.getValue().match(/if/g).length > 1, 'message: You should have at least two if
statements');",
+ "assert(code.match(/else/g).length > 1, 'message: You should have at least two else
statements');",
+ "assert(code.match(/if/g).length > 1, 'message: You should have at least two if
statements');",
"assert(myTest(0) === \"Smaller than 5\", 'message: myTest(4)
should return \"Smaller than 5\"');",
"assert(myTest(5) === \"Between 5 and 10\", 'message: myTest(5)
should return \"Smaller than 5\"');",
"assert(myTest(7) === \"Between 5 and 10\", 'message: myTest(7)
should return \"Between 5 and 10\"');",
@@ -2946,9 +2945,9 @@
},
{
"id": "56533eb9ac21ba0edf2244dc",
- "title": "Chaining If/Else Statements",
+ "title": "Chaining If Else Statements",
"description": [
- "if...else
statements can be chained together for complex logic. Here is pseudocode of multiple chained if
/ else if
statements:",
+ "if/else
statements can be chained together for complex logic. Here is pseudocode of multiple chained if
/ else if
statements:",
"if(condition1) {
statement1
} else if (condition1) {
statement1
} else if (condition3) {
statement3
. . .
} else {
statementN
}
",
"Instructions
",
"Write chained if
/else if
statements to fulfill the following conditions:",
@@ -2956,9 +2955,9 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(editor.getValue().match(/else/g).length > 3, 'message: You should have at least four else
statements');",
- "assert(editor.getValue().match(/if/g).length > 3, 'message: You should have at least four if
statements');",
- "assert(editor.getValue().match(/return/g).length === 5, 'message: You should have five return
statements');",
+ "assert(code.match(/else/g).length > 3, 'message: You should have at least four else
statements');",
+ "assert(code.match(/if/g).length > 3, 'message: You should have at least four if
statements');",
+ "assert(code.match(/return/g).length === 5, 'message: You should have five return
statements');",
"assert(myTest(0) === \"Tiny\", 'message: myTest(0)
should return \"Tiny\"');",
"assert(myTest(4) === \"Tiny\", 'message: myTest(4)
should return \"Tiny\"');",
"assert(myTest(5) === \"Small\", 'message: myTest(5)
should return \"Small\"');",
@@ -3081,11 +3080,12 @@
"id": "56533eb9ac21ba0edf2244dd",
"title": "Selecting from many options with Switch Statements",
"description": [
- "If you have many options to choose from, use a switch
statement. A switch
statement tests a value and can have many case
statements which defines various possible values. Statements are executed from the first matched case
value unless a break
is encountered. Shown here in pseudocode:",
+ "If you have many options to choose from, use a switch
statement. A switch
statement tests a value and can have many case
statements which defines various possible values. Statements are executed from the first matched case
value until a break
is encountered. ",
+ "Here is a pseudocode example:",
"switch (num) {
case value1:
statement1;
break;
case value2:
statement2;
break;
...
case valueN:
statementN;
break;
}
",
"case
values are tested with strict equality (===
). The break
tells JavaScript to stop executing statements. If the break
is omitted, the next statement will be executed.",
"Instructions
",
- "Write a switch statement to set answer
for the following conditions:
1
- \"alpha\"
2
- \"beta\"
3
- \"gamma\"
4
- \"delta\""
+ "Write a switch statement which tests val
and sets answer
for the following conditions:
1
- \"alpha\"
2
- \"beta\"
3
- \"gamma\"
4
- \"delta\""
],
"releasedOn": "January 1, 2016",
"tests": [
@@ -3093,8 +3093,8 @@
"assert(myTest(2) === \"beta\", 'message: myTest(2) should have a value of \"beta\"');",
"assert(myTest(3) === \"gamma\", 'message: myTest(3) should have a value of \"gamma\"');",
"assert(myTest(4) === \"delta\", 'message: myTest(4) should have a value of \"delta\"');",
- "assert(!/else/g.test(editor.getValue()) || !/if/g.test(editor.getValue()), 'message: You should not use any if
or else
statements');",
- "assert(editor.getValue().match(/break/g).length > 2, 'message: You should have at least 3 break
statements');"
+ "assert(!/else/g.test(code) || !/if/g.test(code), 'message: You should not use any if
or else
statements');",
+ "assert(code.match(/break/g).length > 2, 'message: You should have at least 3 break
statements');"
],
"challengeSeed": [
"function myTest(val) {",
@@ -3143,7 +3143,7 @@
"id": "56533eb9ac21ba0edf2244de",
"title": "Adding a default option in Switch statements",
"description": [
- "In a switch
statement you may not be able to specify all possible values as case
statements. Instead, you can add the default
statement which will be executed if no matching case
are found. Think of it like the final else
statement in an if...else
chain.",
+ "In a switch
statement you may not be able to specify all possible values as case
statements. Instead, you can add the default
statement which will be executed if no matching case
statements are found. Think of it like the final else
statement in an if/else
chain.",
"A default
statement should be the last case.",
"switch (num) {
case value1:
statement1
break;
case value2:
statement2;
break;
...
default:
defaultStatement;
}
",
"Instructions
",
@@ -3156,8 +3156,8 @@
"assert(myTest(\"c\") === \"cat\", 'message: myTest(\"c\") should have a value of \"cat\"');",
"assert(myTest(\"d\") === \"stuff\", 'message: myTest(\"d\") should have a value of \"stuff\"');",
"assert(myTest(4) === \"stuff\", 'message: myTest(4) should have a value of \"stuff\"');",
- "assert(!/else/g.test(editor.getValue()) || !/if/g.test(editor.getValue()), 'message: You should not use any if
or else
statements');",
- "assert(editor.getValue().match(/break/g).length > 2, 'message: You should have at least 3 break
statements');"
+ "assert(!/else/g.test(code) || !/if/g.test(code), 'message: You should not use any if
or else
statements');",
+ "assert(code.match(/break/g).length > 2, 'message: You should have at least 3 break
statements');"
],
"challengeSeed": [
"function myTest(val) {",
@@ -3206,7 +3206,7 @@
"id": "56533eb9ac21ba0edf2244df",
"title": "Multiple Identical Options in Switch Statements",
"description": [
- "If the break
statement is omitted from a switch
statement case
, the following case
statement(s) are executed unless a break
is encountered. If you have multiple inputs with the same output, you can represent them in a switch
statement like this:",
+ "If the break
statement is ommitted from a switch
statement's case
, the following case
statement(s) are executed until a break
is encountered. If you have multiple inputs with the same output, you can represent them in a switch
statement like this:",
"switch(val) {
case 1:
case 2:
case 3:
result = \"1, 2, or 3\";
break;
case 4:
result = \"4 alone\";
}
",
"Cases for 1, 2, and 3 will all produce the same result.",
"Instructions
",
@@ -3225,8 +3225,8 @@
"assert(myTest(7) === \"High\", 'message: myTest(7)
should return \"High\"');",
"assert(myTest(8) === \"High\", 'message: myTest(8)
should return \"High\"');",
"assert(myTest(9) === \"High\", 'message: myTest(9)
should return \"High\"');",
- "assert(!/else/g.test(editor.getValue()) || !/if/g.test(editor.getValue()), 'message: You should not use any if
or else
statements');",
- "assert(editor.getValue().match(/case/g).length === 9, 'message: You should have nine case
statements');"
+ "assert(!/else/g.test(code) || !/if/g.test(code), 'message: You should not use any if
or else
statements');",
+ "assert(code.match(/case/g).length === 9, 'message: You should have nine case
statements');"
],
"challengeSeed": [
"function myTest(val) {",
@@ -3277,7 +3277,7 @@
},
{
"id": "56533eb9ac21ba0edf2244e0",
- "title": "Replacing If/Else chains with Switch",
+ "title": "Replacing If Else chains with Switch",
"description": [
"If you have many options to choose from, a switch
statement can be easier to write than many chained if
/if else
statements. The following:",
"if(val === 1) {
answer = \"a\";
} else if(val === 2) {
answer = \"b\";
} else {
answer = \"c\";
}
",
@@ -3288,9 +3288,9 @@
],
"releasedOn": "January 1, 2016",
"tests": [
- "assert(!/else/g.test(editor.getValue()), 'message: You should not use any else
statements');",
- "assert(!/if/g.test(editor.getValue()), 'message: You should not use any if
statements');",
- "assert(editor.getValue().match(/break/g).length === 4, 'message: You should have four break
statements');",
+ "assert(!/else/g.test(code), 'message: You should not use any else
statements');",
+ "assert(!/if/g.test(code), 'message: You should not use any if
statements');",
+ "assert(code.match(/break/g).length === 4, 'message: You should have four break
statements');",
"assert(myTest(\"bob\") === \"Marley\", 'message: myTest(\"bob\")
should be \"Marley\"');",
"assert(myTest(42) === \"The Answer\", 'message: myTest(42)
should be \"The Answer\"');",
"assert(myTest(1) === \"There is no #1\", 'message: myTest(1)
should be \"There is no #1\"');",
@@ -3371,7 +3371,7 @@
"tests": [
"assert(isLess(10,15) === true, 'message: isLess(10,15)
should return true
');",
"assert(isLess(15, 10) === false, 'message: isLess(15,10)
should return true
');",
- "assert(!/if|else/g.test(editor.getValue()), 'message: You should not use any if
or else
statements');"
+ "assert(!/if|else/g.test(code), 'message: You should not use any if
or else
statements');"
],
"challengeSeed": [
"function isLess(a, b) {",
@@ -3585,7 +3585,7 @@
"assert(typeof hatValue === 'string' , 'message: hatValue
should be a string');",
"assert(hatValue === 'ballcap' , 'message: The value of hatValue
should be \"ballcap\"
');",
"assert(typeof shirtValue === 'string' , 'message: shirtValue
should be a string');",
- "assert(shirtValue === 'jersey' , 'message: The value of shirtValue
should be \"jersey\"
');\nassert(editor.getValue().match(/testObj\\.\\w+/g).length > 1, 'message: You should use dot notation twice');"
+ "assert(shirtValue === 'jersey' , 'message: The value of shirtValue
should be \"jersey\"
');\nassert(code.match(/testObj\\.\\w+/g).length > 1, 'message: You should use dot notation twice');"
],
"challengeSeed": [
"// Setup",
@@ -3638,7 +3638,7 @@
"assert(entreeValue === 'hamburger' , 'message: The value of entreeValue
should be \"hamburger\"
');",
"assert(typeof drinkValue === 'string' , 'message: drinkValue
should be a string');",
"assert(drinkValue === 'water' , 'message: The value of drinkValue
should be \"water\"
');",
- "assert(editor.getValue().match(/testObj\\[('|\")[^'\"]+\\1\\]/g).length > 1, 'message: You should use bracket notation twice');"
+ "assert(code.match(/testObj\\[('|\")[^'\"]+\\1\\]/g).length > 1, 'message: You should use bracket notation twice');"
],
"challengeSeed": [
"// Setup",
@@ -3689,7 +3689,7 @@
"assert(typeof playerNumber === 'number', 'message: playerNumber
should be a number');",
"assert(typeof player === 'string', 'message: The variable player
should be a string');",
"assert(player === 'Montana', 'message: The value of player
should be \"Montana\"');",
- "assert(/testObj\\[\\s*playerNumber\\s*\\]/.test(editor.getValue()),'message: You should use bracket notation to access testObj
');"
+ "assert(/testObj\\[\\s*playerNumber\\s*\\]/.test(code),'message: You should use bracket notation to access testObj
');"
],
"challengeSeed": [
"// Setup",
@@ -3735,7 +3735,7 @@
],
"tests": [
"assert(/happy coder/gi.test(myDog.name), 'message: Update myDog
's \"name\"
property to equal \"Happy Coder\".');",
- "assert(/\"name\": \"Coder\"/.test(editor.getValue()), 'message: Do not edit the myDog
definition');"
+ "assert(/\"name\": \"Coder\"/.test(code), 'message: Do not edit the myDog
definition');"
],
"challengeSeed": [
"// Example",
@@ -3781,7 +3781,7 @@
],
"tests": [
"assert(myDog.bark !== undefined, 'message: Add the property \"bark\"
to myDog
.');",
- "assert(!/bark[^\\n]:/.test(editor.getValue()), 'message: Do not add \"bark\"
to the setup section');"
+ "assert(!/bark[^\\n]:/.test(code), 'message: Do not add \"bark\"
to the setup section');"
],
"challengeSeed": [
"// Example",
@@ -3831,7 +3831,7 @@
],
"tests": [
"assert(myDog.tails === undefined, 'message: Delete the property \"tails\"
from myDog
.');",
- "assert(editor.getValue().match(/\"tails\": 1/g).length > 1, 'message: Do not modify the myDog
setup');"
+ "assert(code.match(/\"tails\": 1/g).length > 1, 'message: Do not modify the myDog
setup');"
],
"challengeSeed": [
"// Example",
@@ -3879,9 +3879,9 @@
"id": "56533eb9ac21ba0edf2244ca",
"title": "Using Objects for Lookups",
"description": [
- "Objects can be thought of as a key/value storage, like a dictonary. If you have tabular data, you can use an object to \"lookup\" values rather than a switch
statement or an if...else
chain. This is most useful when you know that your input data is limited to a certain range.",
+ "Objects can be thought of as a key/value storage, like a dictonary. If you have tabular data, you can use an object to \"lookup\" values rather than a switch
statement or an if/else
chain. This is most useful when you know that your input data is limited to a certain range.",
"Here is an example of a simple reverse alphabet lookup:",
- "var alpha = {
1:\"Z\"
2:\"Y\"
3:\"X\"
...
4:\"W\"
24:\"C\"
25:\"B\"
26:\"A\"
};
alpha[2]; // \"Y\"
alpha[24]; // \"C\"
",
+ "var alpha = {
1:\"Z\",
2:\"Y\",
3:\"X\",
...
4:\"W\",
24:\"C\",
25:\"B\",
26:\"A\"
};
alpha[2]; // \"Y\"
alpha[24]; // \"C\"
",
"Instructions
",
"Convert the switch statement into a lookup table called lookup
. Use it to lookup val
and return the associated string."
],
@@ -3897,7 +3897,7 @@
"assert(numberLookup(7) === 'seven', 'message: numberLookup(7)
should equal \"seven\"
');",
"assert(numberLookup(8) === 'eight', 'message: numberLookup(8)
should equal \"eight\"
');",
"assert(numberLookup(9) === 'nine', 'message: numberLookup(9)
should equal \"nine\"
');",
- "assert(!/case|switch|if/g.test(editor.getValue()), 'message: You should not use case
, switch
, or if
statements');"
+ "assert(!/case|switch|if/g.test(code), 'message: You should not use case
, switch
, or if
statements');"
],
"challengeSeed": [
"// Setup",
@@ -3977,11 +3977,11 @@
"id": "567af2437cbaa8c51670a16c",
"title": "Testing Objects for Properties",
"description": [
- "Sometimes it is useful to check of the property of a given object exists or not. We can use the .hasOwnProperty([propname])
method of objects to determine if that object has the given property name. .hasOwnProperty()
returns true
or false
if the property is found or not.",
+ "Sometimes it is useful to check if the property of a given object exists or not. We can use the .hasOwnProperty([propname])
method of objects to determine if that object has the given property name. .hasOwnProperty()
returns true
or false
if the property is found or not.",
"Example",
"var myObj = {
top: \"hat\",
bottom: \"pants\"
};
myObj.hasOwnProperty(\"hat\"); // true
myObj.hasOwnProperty(\"middle\"); // false
",
"Instructions
",
- " Modify function checkObj
to test myObj
for checkProp
. If the property is found, return that property's value. If not return \"Not Found\"
."
+ "Modify the function checkObj
to test myObj
for checkProp
. If the property is found, return that property's value. If not, return \"Not Found\"
."
],
"releasedOn": "January 1, 2016",
"tests": [
@@ -4047,7 +4047,7 @@
"assert(myMusic[1].hasOwnProperty('title') && typeof myMusic[1].title === 'string', 'message: myMusic[1]
should contain a title
property which is a string');",
"assert(myMusic[1].hasOwnProperty('release_year') && typeof myMusic[1].release_year === 'number', 'message: myMusic[1]
should contain a release_year
property which is a number');",
"assert(myMusic[1].hasOwnProperty('formats') && Array.isArray(myMusic[1].formats), 'message: myMusic[1]
should contain a formats
property which is an array');",
- "assert(typeof myMusic[1].formats[0] === 'string' && myMusic[1].formats.length > 1, 'message: formats
should be an array of strings with at least two elements');"
+ "assert(myMusic[1].formats.every(function(item) { return (typeof item === \"string\")}) && myMusic[1].formats.length > 1, 'message: formats
should be an array of strings with at least two elements');"
],
"challengeSeed": [
"var myMusic = [",
@@ -4116,7 +4116,7 @@
"releasedOn": "January 1, 2016",
"tests": [
"assert(gloveBoxContents === \"maps\", 'message: gloveBoxContents
should equal \"maps\"');",
- "assert(/=\\s*myStorage\\.car\\.inside\\[([\"'])glove box\\1\\]/.test(editor.getValue()), 'message: Use dot and bracket notation to access myStorage
');"
+ "assert(/=\\s*myStorage\\.car\\.inside\\[([\"'])glove box\\1\\]/.test(code), 'message: Use dot and bracket notation to access myStorage
');"
],
"challengeSeed": [
"// Setup",
@@ -4175,7 +4175,7 @@
"releasedOn": "January 1, 2016",
"tests": [
"assert(secondTree === \"pine\", 'message: secondTree
should equal \"pine\"');",
- "assert(/=\\s*myPlants\\[1\\].list\\[1\\]/.test(editor.getValue()), 'message: Use dot and bracket notation to access myPlants
');"
+ "assert(/=\\s*myPlants\\[1\\].list\\[1\\]/.test(code), 'message: Use dot and bracket notation to access myPlants
');"
],
"challengeSeed": [
"// Setup",
@@ -4250,7 +4250,7 @@
"id": "56533eb9ac21ba0edf2244cf",
"title": "Record Collection",
"description": [
- "You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and which has several properties. Not all albums have complete information.",
+ "You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.",
"Write a function which takes an id
, a property (prop
), and a value
.",
"For the given id
in collection
:",
"If value
is non-blank (value !== \"\"
), then update or set the value
for the prop
.",
@@ -4379,7 +4379,7 @@
"Use a for
loop to work to push the values 1 through 5 onto myArray
."
],
"tests": [
- "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for
loop for this.');",
+ "assert(code.match(/for\\s*\\(/g).length > 1, 'message: You should be using a for
loop for this.');",
"assert.deepEqual(myArray, [1,2,3,4,5], 'message: myArray
should equal [1,2,3,4,5]
.');"
],
"challengeSeed": [
@@ -4416,7 +4416,7 @@
"Push the odd numbers from 1 through 9 to myArray
using a for
loop."
],
"tests": [
- "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for
loop for this.');",
+ "assert(code.match(/for\\s*\\(/g).length > 1, 'message: You should be using a for
loop for this.');",
"assert.deepEqual(myArray, [1,3,5,7,9], 'message: myArray
should equal [1,3,5,7,9]
.');"
],
"challengeSeed": [
@@ -4454,7 +4454,7 @@
"Push the odd numbers from 9 through 1 to myArray
using a for
loop."
],
"tests": [
- "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for
loop for this.');",
+ "assert(code.match(/for\\s*\\(/g).length > 1, 'message: You should be using a for
loop for this.');",
"assert.deepEqual(myArray, [9,7,5,3,1], 'message: myArray
should equal [9,7,5,3,1]
.');"
],
"challengeSeed": [
@@ -4491,7 +4491,7 @@
"tests": [
"assert(total !== 'undefined', 'message: total
should be defined');",
"assert(total === 20, 'message: total
should equal 20');",
- "assert(!/20/.test(editor.getValue()), 'message: Do not set total
to 20 directly');"
+ "assert(!/20/.test(code), 'message: Do not set total
to 20 directly');"
],
"challengeSeed": [
"// Example",
@@ -4595,7 +4595,7 @@
"Push the numbers 0 through 4 to myArray
using a while
loop."
],
"tests": [
- "assert(editor.getValue().match(/while/g), 'message: You should be using a while
loop for this.');",
+ "assert(code.match(/while/g), 'message: You should be using a while
loop for this.');",
"assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray
should equal [0,1,2,3,4]
.');"
],
"challengeSeed": [
@@ -4618,7 +4618,7 @@
"description": [
"One of the simplest and most widely known ciphers is a Caesar cipher
, also known as a shift cipher
. In a shift cipher
the meanings of the letters are shifted by some set amount. ",
"A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.",
- "Write a function which takes a ROT13
encoded string as input and returns a decoded string. All letters will be uppercase. Do not transform any non-alphabetic character (IE: spaces, punctiation), but do pass them on.",
+ "Write a function which takes a ROT13
encoded string as input and returns a decoded string. All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.",
"The provided code transforms the input into an array for you, codeArr
. Place the decoded values into the decodedArr
array where the provided code will transform it back into a string."
],
"releasedOn": "January 1, 2016",
@@ -4693,7 +4693,7 @@
"tests": [
"assert(typeof(myFunction()) === \"number\", 'message: myFunction
should return a random number.');",
"assert((myFunction()+''). match(/\\./g), 'message: The number returned by myFunction
should be a decimal.');",
- "assert(editor.getValue().match(/Math\\.random/g).length >= 0, 'message: You should be using Math.random
to generate the random decimal number.');"
+ "assert(code.match(/Math\\.random/g).length >= 0, 'message: You should be using Math.random
to generate the random decimal number.');"
],
"challengeSeed": [
"function myFunction() {",
@@ -4728,9 +4728,9 @@
],
"tests": [
"assert(typeof(myFunction()) === \"number\" && (function(){var r = myFunction();return Math.floor(r) === r;})(), 'message: The result of myFunction
should be a whole number.');",
- "assert(editor.getValue().match(/Math.random/g).length > 1, 'message: You should be using Math.random
to generate a random number.');",
- "assert(editor.getValue().match(/\\(\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\*\\s*?10\\s*?\\)/g) || editor.getValue().match(/\\(\\s*?10\\s*?\\*\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\)/g), 'message: You should have multiplied the result of Math.random
by 10 to make it a number that is between zero and nine.');",
- "assert(editor.getValue().match(/Math.floor/g).length > 1, 'message: You should use Math.floor
to remove the decimal part of the number.');"
+ "assert(code.match(/Math.random/g).length > 1, 'message: You should be using Math.random
to generate a random number.');",
+ "assert(code.match(/\\(\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\*\\s*?10\\s*?\\)/g) || code.match(/\\(\\s*?10\\s*?\\*\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\)/g), 'message: You should have multiplied the result of Math.random
by 10 to make it a number that is between zero and nine.');",
+ "assert(code.match(/Math.floor/g).length > 1, 'message: You should use Math.floor
to remove the decimal part of the number.');"
],
"challengeSeed": [
"var randomNumberBetween0and19 = Math.floor(Math.random() * 20);",
@@ -4763,7 +4763,7 @@
"assert(myFunction() >= myMin, 'message: The random number generated by myFunction
should be greater than or equal to your minimum number, myMin
.');",
"assert(myFunction() <= myMax, 'message: The random number generated by myFunction
should be less than or equal to your maximum number, myMax
.');",
"assert(myFunction() % 1 === 0 , 'message: The random number generated by myFunction
should be an integer, not a decimal.');",
- "assert((function(){if(editor.getValue().match(/myMax/g).length > 1 && editor.getValue().match(/myMin/g).length > 2 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return true;}else{return false;}})(), 'message: myFunction()
should use use both myMax
and myMin
, and return a random number in your range.');"
+ "assert((function(){if(code.match(/myMax/g).length > 1 && code.match(/myMin/g).length > 2 && code.match(/Math.floor/g) && code.match(/Math.random/g)){return true;}else{return false;}})(), 'message: myFunction()
should use use both myMax
and myMin
, and return a random number in your range.');"
],
"challengeSeed": [
"var ourMin = 1;",
@@ -4810,7 +4810,7 @@
],
"tests": [
"assert(test==2, 'message: Your regular expression
should find two occurrences of the word and
.');",
- "assert(editor.getValue().match(/\\/and\\/gi/), 'message: Use regular expressions
to find the word and
in testString
.');"
+ "assert(code.match(/\\/and\\/gi/), 'message: Use regular expressions
to find the word and
in testString
.');"
],
"head": [
""
@@ -4847,7 +4847,7 @@
"Use the \\d
selector to select the number of numbers in the string, allowing for the possibility of multi-digit numbers."
],
"tests": [
- "assert(editor.getValue().match(/\\/\\\\d\\+\\//g), 'message: Use the /\\d+/g
regular expression to find the numbers in testString
.');",
+ "assert(code.match(/\\/\\\\d\\+\\//g), 'message: Use the /\\d+/g
regular expression to find the numbers in testString
.');",
"assert(test === 2, 'message: Your regular expression should find two numbers in testString
.');"
],
"head": [
@@ -4881,7 +4881,7 @@
"Use it to select all the whitespace characters in the sentence string."
],
"tests": [
- "assert(editor.getValue().match(/\\/\\\\s\\+\\//g), 'message: Use the /\\s+/g
regular expression to find the spaces in testString
.');",
+ "assert(code.match(/\\/\\\\s\\+\\//g), 'message: Use the /\\s+/g
regular expression to find the spaces in testString
.');",
"assert(test === 7, 'message: Your regular expression should find seven spaces in testString
.');"
],
"head": [
@@ -4912,7 +4912,7 @@
"Use /\\S/g
to count the number of non-whitespace characters in testString
."
],
"tests": [
- "assert(editor.getValue().match(/\\/\\\\S\\/g/g), 'message: Use the /\\S/g
regular expression to find non-space characters in testString
.');",
+ "assert(code.match(/\\/\\\\S\\/g/g), 'message: Use the /\\S/g
regular expression to find non-space characters in testString
.');",
"assert(test === 49, 'message: Your regular expression should find forty nine non-space characters in the testString
.');"
],
"head": [
@@ -5589,4 +5589,4 @@
"challengeType": "0"
}
]
-}
+}
\ No newline at end of file