fix(challenge-md): Fix quotes that failed in the transform

This commit is contained in:
Bouncey
2018-10-08 01:01:53 +01:00
committed by mrugesh mohapatra
parent 392b28fa55
commit a859035023
1333 changed files with 5710 additions and 5710 deletions

View File

@@ -25,9 +25,9 @@ Create a variable called <code>myData</code> and set it to equal the first value
```yml
tests:
- text: The variable <code>myData</code> should equal the first value of <code>myArray</code>.
testString: 'assert((function(){if(typeof myArray !== ''undefined'' && typeof myData !== ''undefined'' && myArray[0] === myData){return true;}else{return false;}})(), ''The variable <code>myData</code> should equal the first value of <code>myArray</code>.'');'
testString: 'assert((function(){if(typeof myArray !== "undefined" && typeof myData !== "undefined" && myArray[0] === myData){return true;}else{return false;}})(), "The variable <code>myData</code> should equal the first value of <code>myArray</code>.");'
- text: The data in variable <code>myArray</code> should be accessed using bracket notation.
testString: 'assert((function(){if(code.match(/\s*=\s*myArray\[0\]/g)){return true;}else{return false;}})(), ''The data in variable <code>myArray</code> should be accessed using bracket notation.'');'
testString: 'assert((function(){if(code.match(/\s*=\s*myArray\[0\]/g)){return true;}else{return false;}})(), "The data in variable <code>myArray</code> should be accessed using bracket notation.");'
```

View File

@@ -24,9 +24,9 @@ Using bracket notation select an element from <code>myArray</code> such that <co
```yml
tests:
- text: <code>myData</code> should be equal to <code>8</code>.
testString: 'assert(myData === 8, ''<code>myData</code> should be equal to <code>8</code>.'');'
testString: 'assert(myData === 8, "<code>myData</code> should be equal to <code>8</code>.");'
- text: You should be using bracket notation to read the correct value from <code>myArray</code>.
testString: 'assert(/myArray\[2\]\[1\]/g.test(code) && !/myData\s*=\s*(?:.*[-+*/%]|\d)/g.test(code), ''You should be using bracket notation to read the correct value from <code>myArray</code>.'');'
testString: 'assert(/myArray\[2\]\[1\]/g.test(code) && !/myData\s*=\s*(?:.*[-+*/%]|\d)/g.test(code), "You should be using bracket notation to read the correct value from <code>myArray</code>.");'
```

View File

@@ -23,9 +23,9 @@ Retrieve the second tree from the variable <code>myPlants</code> using object do
```yml
tests:
- text: <code>secondTree</code> should equal "pine"
testString: 'assert(secondTree === "pine", ''<code>secondTree</code> should equal "pine"'');'
testString: 'assert(secondTree === "pine", "<code>secondTree</code> should equal "pine"");'
- text: Use dot and bracket notation to access <code>myPlants</code>
testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), ''Use dot and bracket notation to access <code>myPlants</code>'');'
testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), "Use dot and bracket notation to access <code>myPlants</code>");'
```
@@ -39,7 +39,7 @@ tests:
```js
// Setup
var myPlants = [
{
{
type: "flowers",
list: [
"rose",
@@ -54,7 +54,7 @@ var myPlants = [
"pine",
"birch"
]
}
}
];
// Only change code below this line
@@ -83,7 +83,7 @@ console.info('after the test');
```js
var myPlants = [
{
{
type: "flowers",
list: [
"rose",
@@ -98,7 +98,7 @@ var myPlants = [
"pine",
"birch"
]
}
}
];
// Only change code below this line

View File

@@ -23,9 +23,9 @@ Access the <code>myStorage</code> object and assign the contents of the <code>gl
```yml
tests:
- text: <code>gloveBoxContents</code> should equal "maps"
testString: 'assert(gloveBoxContents === "maps", ''<code>gloveBoxContents</code> should equal "maps"'');'
testString: 'assert(gloveBoxContents === "maps", "<code>gloveBoxContents</code> should equal "maps"");'
- text: Use dot and bracket notation to access <code>myStorage</code>
testString: 'assert(/=\s*myStorage\.car\.inside\[\s*("|'')glove box\1\s*\]/g.test(code), ''Use dot and bracket notation to access <code>myStorage</code>'');'
testString: 'assert(/=\s*myStorage\.car\.inside\[\s*("|")glove box\1\s*\]/g.test(code), "Use dot and bracket notation to access <code>myStorage</code>");'
```
@@ -73,13 +73,13 @@ console.info('after the test');
```js
var myStorage = {
"car":{
"inside":{
var myStorage = {
"car":{
"inside":{
"glove box":"maps",
"passenger seat":"crumbs"
},
"outside":{
"outside":{
"trunk":"jack"
}
}

View File

@@ -25,15 +25,15 @@ Read the values of the properties <code>"an entree"</code> and <code>"the drink"
```yml
tests:
- text: <code>entreeValue</code> should be a string
testString: 'assert(typeof entreeValue === ''string'' , ''<code>entreeValue</code> should be a string'');'
testString: 'assert(typeof entreeValue === "string" , "<code>entreeValue</code> should be a string");'
- text: The value of <code>entreeValue</code> should be <code>"hamburger"</code>
testString: 'assert(entreeValue === ''hamburger'' , ''The value of <code>entreeValue</code> should be <code>"hamburger"</code>'');'
testString: 'assert(entreeValue === "hamburger" , "The value of <code>entreeValue</code> should be <code>"hamburger"</code>");'
- text: <code>drinkValue</code> should be a string
testString: 'assert(typeof drinkValue === ''string'' , ''<code>drinkValue</code> should be a string'');'
testString: 'assert(typeof drinkValue === "string" , "<code>drinkValue</code> should be a string");'
- text: The value of <code>drinkValue</code> should be <code>"water"</code>
testString: 'assert(drinkValue === ''water'' , ''The value of <code>drinkValue</code> should be <code>"water"</code>'');'
testString: 'assert(drinkValue === "water" , "The value of <code>drinkValue</code> should be <code>"water"</code>");'
- text: You should use bracket notation twice
testString: 'assert(code.match(/testObj\s*?\[(''|")[^''"]+\1\]/g).length > 1, ''You should use bracket notation twice'');'
testString: 'assert(code.match(/testObj\s*?\[("|")[^""]+\1\]/g).length > 1, "You should use bracket notation twice");'
```

View File

@@ -23,15 +23,15 @@ Read in the property values of <code>testObj</code> using dot notation. Set the
```yml
tests:
- text: <code>hatValue</code> should be a string
testString: 'assert(typeof hatValue === ''string'' , ''<code>hatValue</code> should be a string'');'
testString: 'assert(typeof hatValue === "string" , "<code>hatValue</code> should be a string");'
- text: The value of <code>hatValue</code> should be <code>"ballcap"</code>
testString: 'assert(hatValue === ''ballcap'' , ''The value of <code>hatValue</code> should be <code>"ballcap"</code>'');'
testString: 'assert(hatValue === "ballcap" , "The value of <code>hatValue</code> should be <code>"ballcap"</code>");'
- text: <code>shirtValue</code> should be a string
testString: 'assert(typeof shirtValue === ''string'' , ''<code>shirtValue</code> should be a string'');'
testString: 'assert(typeof shirtValue === "string" , "<code>shirtValue</code> should be a string");'
- text: The value of <code>shirtValue</code> should be <code>"jersey"</code>
testString: 'assert(shirtValue === ''jersey'' , ''The value of <code>shirtValue</code> should be <code>"jersey"</code>'');'
testString: 'assert(shirtValue === "jersey" , "The value of <code>shirtValue</code> should be <code>"jersey"</code>");'
- text: You should use dot notation twice
testString: 'assert(code.match(/testObj\.\w+/g).length > 1, ''You should use dot notation twice'');'
testString: 'assert(code.match(/testObj\.\w+/g).length > 1, "You should use dot notation twice");'
```
@@ -81,7 +81,7 @@ var testObj = {
"shoes": "cleats"
};
var hatValue = testObj.hat;
var hatValue = testObj.hat;
var shirtValue = testObj.shirt;
```

View File

@@ -28,17 +28,17 @@ Use the <code>playerNumber</code> variable to look up player <code>16</code> in
```yml
tests:
- text: <code>playerNumber</code> should be a number
testString: 'assert(typeof playerNumber === ''number'', ''<code>playerNumber</code> should be a number'');'
testString: 'assert(typeof playerNumber === "number", "<code>playerNumber</code> should be a number");'
- text: The variable <code>player</code> should be a string
testString: 'assert(typeof player === ''string'', ''The variable <code>player</code> should be a string'');'
testString: 'assert(typeof player === "string", "The variable <code>player</code> should be a string");'
- text: The value of <code>player</code> should be "Montana"
testString: 'assert(player === ''Montana'', ''The value of <code>player</code> should be "Montana"'');'
testString: 'assert(player === "Montana", "The value of <code>player</code> should be "Montana"");'
- text: You should use bracket notation to access <code>testObj</code>
testString: 'assert(/testObj\s*?\[.*?\]/.test(code),''You should use bracket notation to access <code>testObj</code>'');'
testString: 'assert(/testObj\s*?\[.*?\]/.test(code),"You should use bracket notation to access <code>testObj</code>");'
- text: You should not assign the value <code>Montana</code> to the variable <code>player</code> directly.
testString: 'assert(!code.match(/player\s*=\s*"|\''\s*Montana\s*"|\''\s*;/gi),''You should not assign the value <code>Montana</code> to the variable <code>player</code> directly.'');'
testString: 'assert(!code.match(/player\s*=\s*"|\"\s*Montana\s*"|\"\s*;/gi),"You should not assign the value <code>Montana</code> to the variable <code>player</code> directly.");'
- text: You should be using the variable <code>playerNumber</code> in your bracket notation
testString: 'assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code),''You should be using the variable <code>playerNumber</code> in your bracket notation'');'
testString: 'assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code),"You should be using the variable <code>playerNumber</code> in your bracket notation");'
```

View File

@@ -8,7 +8,7 @@ challengeType: 1
<section id='description'>
You can add new properties to existing JavaScript objects the same way you would modify them.
Here's how we would add a <code>"bark"</code> property to <code>ourDog</code>:
<code>ourDog.bark = "bow-wow";</code>
<code>ourDog.bark = "bow-wow";</code>
or
<code>ourDog["bark"] = "bow-wow";</code>
Now when we evaluate <code>ourDog.bark</code>, we'll get his bark, "bow-wow".
@@ -25,9 +25,9 @@ Add a <code>"bark"</code> property to <code>myDog</code> and set it to a dog sou
```yml
tests:
- text: Add the property <code>"bark"</code> to <code>myDog</code>.
testString: 'assert(myDog.bark !== undefined, ''Add the property <code>"bark"</code> to <code>myDog</code>.'');'
testString: 'assert(myDog.bark !== undefined, "Add the property <code>"bark"</code> to <code>myDog</code>.");'
- text: Do not add <code>"bark"</code> to the setup section
testString: 'assert(!/bark[^\n]:/.test(code), ''Do not add <code>"bark"</code> to the setup section'');'
testString: 'assert(!/bark[^\n]:/.test(code), "Do not add <code>"bark"</code> to the setup section");'
```

View File

@@ -24,9 +24,9 @@ Change the <code>0</code> so that sum will equal <code>20</code>.
```yml
tests:
- text: <code>sum</code> should equal <code>20</code>
testString: 'assert(sum === 20, ''<code>sum</code> should equal <code>20</code>'');'
testString: 'assert(sum === 20, "<code>sum</code> should equal <code>20</code>");'
- text: Use the <code>+</code> operator
testString: 'assert(/\+/.test(code), ''Use the <code>+</code> operator'');'
testString: 'assert(/\+/.test(code), "Use the <code>+</code> operator");'
```

View File

@@ -23,21 +23,21 @@ Write a switch statement to set <code>answer</code> for the following conditions
```yml
tests:
- text: <code>switchOfStuff("a")</code> should have a value of "apple"
testString: 'assert(switchOfStuff("a") === "apple", ''<code>switchOfStuff("a")</code> should have a value of "apple"'');'
testString: 'assert(switchOfStuff("a") === "apple", "<code>switchOfStuff("a")</code> should have a value of "apple"");'
- text: <code>switchOfStuff("b")</code> should have a value of "bird"
testString: 'assert(switchOfStuff("b") === "bird", ''<code>switchOfStuff("b")</code> should have a value of "bird"'');'
testString: 'assert(switchOfStuff("b") === "bird", "<code>switchOfStuff("b")</code> should have a value of "bird"");'
- text: <code>switchOfStuff("c")</code> should have a value of "cat"
testString: 'assert(switchOfStuff("c") === "cat", ''<code>switchOfStuff("c")</code> should have a value of "cat"'');'
testString: 'assert(switchOfStuff("c") === "cat", "<code>switchOfStuff("c")</code> should have a value of "cat"");'
- text: <code>switchOfStuff("d")</code> should have a value of "stuff"
testString: 'assert(switchOfStuff("d") === "stuff", ''<code>switchOfStuff("d")</code> should have a value of "stuff"'');'
testString: 'assert(switchOfStuff("d") === "stuff", "<code>switchOfStuff("d")</code> should have a value of "stuff"");'
- text: <code>switchOfStuff(4)</code> should have a value of "stuff"
testString: 'assert(switchOfStuff(4) === "stuff", ''<code>switchOfStuff(4)</code> should have a value of "stuff"'');'
testString: 'assert(switchOfStuff(4) === "stuff", "<code>switchOfStuff(4)</code> should have a value of "stuff"");'
- text: You should not use any <code>if</code> or <code>else</code> statements
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), ''You should not use any <code>if</code> or <code>else</code> statements'');'
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
- text: You should use a <code>default</code> statement
testString: 'assert(switchOfStuff("string-to-trigger-default-case") === "stuff", ''You should use a <code>default</code> statement'');'
testString: 'assert(switchOfStuff("string-to-trigger-default-case") === "stuff", "You should use a <code>default</code> statement");'
- text: You should have at least 3 <code>break</code> statements
testString: 'assert(code.match(/break/g).length > 2, ''You should have at least 3 <code>break</code> statements'');'
testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 <code>break</code> statements");'
```
@@ -52,11 +52,11 @@ tests:
function switchOfStuff(val) {
var answer = "";
// Only change code below this line
// Only change code above this line
return answer;
// Only change code above this line
return answer;
}
// Change this value to test
@@ -91,7 +91,7 @@ function switchOfStuff(val) {
default:
answer = "stuff";
}
return answer;
return answer;
}
```

View File

@@ -21,9 +21,9 @@ Set <code>someAdjective</code> and append it to <code>myStr</code> using the <co
```yml
tests:
- text: <code>someAdjective</code> should be set to a string at least 3 characters long
testString: 'assert(typeof someAdjective !== ''undefined'' && someAdjective.length > 2, ''<code>someAdjective</code> should be set to a string at least 3 characters long'');'
testString: 'assert(typeof someAdjective !== "undefined" && someAdjective.length > 2, "<code>someAdjective</code> should be set to a string at least 3 characters long");'
- text: Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator
testString: 'assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0, ''Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator'');'
testString: 'assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0, "Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator");'
```

View File

@@ -8,7 +8,7 @@ guideUrl: 'https://guide.freecodecamp.org/certificates/assignment-with-a-returne
## Description
<section id='description'>
If you'll recall from our discussion of <a href="javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank">Storing Values with the Assignment Operator</a>, everything to the right of the equal sign is resolved before the value is assigned. This means we can take the return value of a function and assign it to a variable.
Assume we have pre-defined a function <code>sum</code> which adds two numbers together, then:
Assume we have pre-defined a function <code>sum</code> which adds two numbers together, then:
<code>ourSum = sum(5, 12);</code>
will call <code>sum</code> function, which returns a value of <code>17</code> and assigns it to <code>ourSum</code> variable.
</section>
@@ -24,9 +24,9 @@ Call the <code>processArg</code> function with an argument of <code>7</code> and
```yml
tests:
- text: <code>processed</code> should have a value of <code>2</code>
testString: 'assert(processed === 2, ''<code>processed</code> should have a value of <code>2</code>'');'
testString: 'assert(processed === 2, "<code>processed</code> should have a value of <code>2</code>");'
- text: You should assign <code>processArg</code> to <code>processed</code>
testString: 'assert(/processed\s*=\s*processArg\(\s*7\s*\)\s*;/.test(code), ''You should assign <code>processArg</code> to <code>processed</code>'');'
testString: 'assert(/processed\s*=\s*processArg\(\s*7\s*\)\s*;/.test(code), "You should assign <code>processArg</code> to <code>processed</code>");'
```

View File

@@ -28,15 +28,15 @@ You can set these object properties to whatever values you want, as long <code>"
```yml
tests:
- text: <code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.
testString: 'assert((function(z){if(z.hasOwnProperty("name") && z.name !== undefined && typeof z.name === "string"){return true;}else{return false;}})(myDog), ''<code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.'');'
testString: 'assert((function(z){if(z.hasOwnProperty("name") && z.name !== undefined && typeof z.name === "string"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.");'
- text: <code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.
testString: 'assert((function(z){if(z.hasOwnProperty("legs") && z.legs !== undefined && typeof z.legs === "number"){return true;}else{return false;}})(myDog), ''<code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.'');'
testString: 'assert((function(z){if(z.hasOwnProperty("legs") && z.legs !== undefined && typeof z.legs === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.");'
- text: <code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.
testString: 'assert((function(z){if(z.hasOwnProperty("tails") && z.tails !== undefined && typeof z.tails === "number"){return true;}else{return false;}})(myDog), ''<code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.'');'
testString: 'assert((function(z){if(z.hasOwnProperty("tails") && z.tails !== undefined && typeof z.tails === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.");'
- text: <code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.
testString: 'assert((function(z){if(z.hasOwnProperty("friends") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), ''<code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.'');'
testString: 'assert((function(z){if(z.hasOwnProperty("friends") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.");'
- text: <code>myDog</code> should only contain all the given properties.
testString: 'assert((function(z){return Object.keys(z).length === 4;})(myDog), ''<code>myDog</code> should only contain all the given properties.'');'
testString: 'assert((function(z){return Object.keys(z).length === 4;})(myDog), "<code>myDog</code> should only contain all the given properties.");'
```
@@ -59,10 +59,10 @@ var ourDog = {
// Only change code below this line.
var myDog = {
};
```
@@ -89,7 +89,7 @@ var myDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
"friends": ["everything!"]
};
```

View File

@@ -22,31 +22,31 @@ Write chained <code>if</code>/<code>else if</code> statements to fulfill the fol
```yml
tests:
- text: You should have at least four <code>else</code> statements
testString: 'assert(code.match(/else/g).length > 3, ''You should have at least four <code>else</code> statements'');'
testString: 'assert(code.match(/else/g).length > 3, "You should have at least four <code>else</code> statements");'
- text: You should have at least four <code>if</code> statements
testString: 'assert(code.match(/if/g).length > 3, ''You should have at least four <code>if</code> statements'');'
testString: 'assert(code.match(/if/g).length > 3, "You should have at least four <code>if</code> statements");'
- text: You should have at least one <code>return</code> statement
testString: 'assert(code.match(/return/g).length >= 1, ''You should have at least one <code>return</code> statement'');'
testString: 'assert(code.match(/return/g).length >= 1, "You should have at least one <code>return</code> statement");'
- text: <code>testSize(0)</code> should return "Tiny"
testString: 'assert(testSize(0) === "Tiny", ''<code>testSize(0)</code> should return "Tiny"'');'
testString: 'assert(testSize(0) === "Tiny", "<code>testSize(0)</code> should return "Tiny"");'
- text: <code>testSize(4)</code> should return "Tiny"
testString: 'assert(testSize(4) === "Tiny", ''<code>testSize(4)</code> should return "Tiny"'');'
testString: 'assert(testSize(4) === "Tiny", "<code>testSize(4)</code> should return "Tiny"");'
- text: <code>testSize(5)</code> should return "Small"
testString: 'assert(testSize(5) === "Small", ''<code>testSize(5)</code> should return "Small"'');'
testString: 'assert(testSize(5) === "Small", "<code>testSize(5)</code> should return "Small"");'
- text: <code>testSize(8)</code> should return "Small"
testString: 'assert(testSize(8) === "Small", ''<code>testSize(8)</code> should return "Small"'');'
testString: 'assert(testSize(8) === "Small", "<code>testSize(8)</code> should return "Small"");'
- text: <code>testSize(10)</code> should return "Medium"
testString: 'assert(testSize(10) === "Medium", ''<code>testSize(10)</code> should return "Medium"'');'
testString: 'assert(testSize(10) === "Medium", "<code>testSize(10)</code> should return "Medium"");'
- text: <code>testSize(14)</code> should return "Medium"
testString: 'assert(testSize(14) === "Medium", ''<code>testSize(14)</code> should return "Medium"'');'
testString: 'assert(testSize(14) === "Medium", "<code>testSize(14)</code> should return "Medium"");'
- text: <code>testSize(15)</code> should return "Large"
testString: 'assert(testSize(15) === "Large", ''<code>testSize(15)</code> should return "Large"'');'
testString: 'assert(testSize(15) === "Large", "<code>testSize(15)</code> should return "Large"");'
- text: <code>testSize(17)</code> should return "Large"
testString: 'assert(testSize(17) === "Large", ''<code>testSize(17)</code> should return "Large"'');'
testString: 'assert(testSize(17) === "Large", "<code>testSize(17)</code> should return "Large"");'
- text: <code>testSize(20)</code> should return "Huge"
testString: 'assert(testSize(20) === "Huge", ''<code>testSize(20)</code> should return "Huge"'');'
testString: 'assert(testSize(20) === "Huge", "<code>testSize(20)</code> should return "Huge"");'
- text: <code>testSize(25)</code> should return "Huge"
testString: 'assert(testSize(25) === "Huge", ''<code>testSize(25)</code> should return "Huge"'');'
testString: 'assert(testSize(25) === "Huge", "<code>testSize(25)</code> should return "Huge"");'
```
@@ -60,8 +60,8 @@ tests:
```js
function testSize(num) {
// Only change code below this line
return "Change Me";
// Only change code above this line
}

View File

@@ -26,9 +26,9 @@ Try creating one of each type of comment.
```yml
tests:
- text: Create a <code>//</code> style comment that contains at least five letters.
testString: 'assert(code.match(/(\/\/)...../g), ''Create a <code>//</code> style comment that contains at least five letters.'');'
testString: 'assert(code.match(/(\/\/)...../g), "Create a <code>//</code> style comment that contains at least five letters.");'
- text: Create a <code>/* */</code> style comment that contains at least five letters.
testString: 'assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm), ''Create a <code>/* */</code> style comment that contains at least five letters.'');'
testString: 'assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm), "Create a <code>/* */</code> style comment that contains at least five letters.");'
```

View File

@@ -25,13 +25,13 @@ Add the <code>equality operator</code> to the indicated line so that the functio
```yml
tests:
- text: <code>testEqual(10)</code> should return "Not Equal"
testString: 'assert(testEqual(10) === "Not Equal", ''<code>testEqual(10)</code> should return "Not Equal"'');'
testString: 'assert(testEqual(10) === "Not Equal", "<code>testEqual(10)</code> should return "Not Equal"");'
- text: <code>testEqual(12)</code> should return "Equal"
testString: 'assert(testEqual(12) === "Equal", ''<code>testEqual(12)</code> should return "Equal"'');'
testString: 'assert(testEqual(12) === "Equal", "<code>testEqual(12)</code> should return "Equal"");'
- text: <code>testEqual("12")</code> should return "Equal"
testString: 'assert(testEqual("12") === "Equal", ''<code>testEqual("12")</code> should return "Equal"'');'
testString: 'assert(testEqual("12") === "Equal", "<code>testEqual("12")</code> should return "Equal"");'
- text: You should use the <code>==</code> operator
testString: 'assert(code.match(/==/g) && !code.match(/===/g), ''You should use the <code>==</code> operator'');'
testString: 'assert(code.match(/==/g) && !code.match(/===/g), "You should use the <code>==</code> operator");'
```

View File

@@ -23,21 +23,21 @@ Add the <code>greater than</code> operator to the indicated lines so that the re
```yml
tests:
- text: <code>testGreaterThan(0)</code> should return "10 or Under"
testString: 'assert(testGreaterThan(0) === "10 or Under", ''<code>testGreaterThan(0)</code> should return "10 or Under"'');'
testString: 'assert(testGreaterThan(0) === "10 or Under", "<code>testGreaterThan(0)</code> should return "10 or Under"");'
- text: <code>testGreaterThan(10)</code> should return "10 or Under"
testString: 'assert(testGreaterThan(10) === "10 or Under", ''<code>testGreaterThan(10)</code> should return "10 or Under"'');'
testString: 'assert(testGreaterThan(10) === "10 or Under", "<code>testGreaterThan(10)</code> should return "10 or Under"");'
- text: <code>testGreaterThan(11)</code> should return "Over 10"
testString: 'assert(testGreaterThan(11) === "Over 10", ''<code>testGreaterThan(11)</code> should return "Over 10"'');'
testString: 'assert(testGreaterThan(11) === "Over 10", "<code>testGreaterThan(11)</code> should return "Over 10"");'
- text: <code>testGreaterThan(99)</code> should return "Over 10"
testString: 'assert(testGreaterThan(99) === "Over 10", ''<code>testGreaterThan(99)</code> should return "Over 10"'');'
testString: 'assert(testGreaterThan(99) === "Over 10", "<code>testGreaterThan(99)</code> should return "Over 10"");'
- text: <code>testGreaterThan(100)</code> should return "Over 10"
testString: 'assert(testGreaterThan(100) === "Over 10", ''<code>testGreaterThan(100)</code> should return "Over 10"'');'
testString: 'assert(testGreaterThan(100) === "Over 10", "<code>testGreaterThan(100)</code> should return "Over 10"");'
- text: <code>testGreaterThan(101)</code> should return "Over 100"
testString: 'assert(testGreaterThan(101) === "Over 100", ''<code>testGreaterThan(101)</code> should return "Over 100"'');'
testString: 'assert(testGreaterThan(101) === "Over 100", "<code>testGreaterThan(101)</code> should return "Over 100"");'
- text: <code>testGreaterThan(150)</code> should return "Over 100"
testString: 'assert(testGreaterThan(150) === "Over 100", ''<code>testGreaterThan(150)</code> should return "Over 100"'');'
testString: 'assert(testGreaterThan(150) === "Over 100", "<code>testGreaterThan(150)</code> should return "Over 100"");'
- text: You should use the <code>&gt;</code> operator at least twice
testString: 'assert(code.match(/val\s*>\s*(''|")*\d+(''|")*/g).length > 1, ''You should use the <code>&gt;</code> operator at least twice'');'
testString: 'assert(code.match(/val\s*>\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&gt;</code> operator at least twice");'
```
@@ -53,7 +53,7 @@ function testGreaterThan(val) {
if (val) { // Change this line
return "Over 100";
}
if (val) { // Change this line
return "Over 10";
}

View File

@@ -23,21 +23,21 @@ Add the <code>greater than or equal to</code> operator to the indicated lines so
```yml
tests:
- text: <code>testGreaterOrEqual(0)</code> should return "Less than 10"
testString: 'assert(testGreaterOrEqual(0) === "Less than 10", ''<code>testGreaterOrEqual(0)</code> should return "Less than 10"'');'
testString: 'assert(testGreaterOrEqual(0) === "Less than 10", "<code>testGreaterOrEqual(0)</code> should return "Less than 10"");'
- text: <code>testGreaterOrEqual(9)</code> should return "Less than 10"
testString: 'assert(testGreaterOrEqual(9) === "Less than 10", ''<code>testGreaterOrEqual(9)</code> should return "Less than 10"'');'
testString: 'assert(testGreaterOrEqual(9) === "Less than 10", "<code>testGreaterOrEqual(9)</code> should return "Less than 10"");'
- text: <code>testGreaterOrEqual(10)</code> should return "10 or Over"
testString: 'assert(testGreaterOrEqual(10) === "10 or Over", ''<code>testGreaterOrEqual(10)</code> should return "10 or Over"'');'
testString: 'assert(testGreaterOrEqual(10) === "10 or Over", "<code>testGreaterOrEqual(10)</code> should return "10 or Over"");'
- text: <code>testGreaterOrEqual(11)</code> should return "10 or Over"
testString: 'assert(testGreaterOrEqual(11) === "10 or Over", ''<code>testGreaterOrEqual(11)</code> should return "10 or Over"'');'
testString: 'assert(testGreaterOrEqual(11) === "10 or Over", "<code>testGreaterOrEqual(11)</code> should return "10 or Over"");'
- text: <code>testGreaterOrEqual(19)</code> should return "10 or Over"
testString: 'assert(testGreaterOrEqual(19) === "10 or Over", ''<code>testGreaterOrEqual(19)</code> should return "10 or Over"'');'
testString: 'assert(testGreaterOrEqual(19) === "10 or Over", "<code>testGreaterOrEqual(19)</code> should return "10 or Over"");'
- text: <code>testGreaterOrEqual(100)</code> should return "20 or Over"
testString: 'assert(testGreaterOrEqual(100) === "20 or Over", ''<code>testGreaterOrEqual(100)</code> should return "20 or Over"'');'
testString: 'assert(testGreaterOrEqual(100) === "20 or Over", "<code>testGreaterOrEqual(100)</code> should return "20 or Over"");'
- text: <code>testGreaterOrEqual(21)</code> should return "20 or Over"
testString: 'assert(testGreaterOrEqual(21) === "20 or Over", ''<code>testGreaterOrEqual(21)</code> should return "20 or Over"'');'
testString: 'assert(testGreaterOrEqual(21) === "20 or Over", "<code>testGreaterOrEqual(21)</code> should return "20 or Over"");'
- text: You should use the <code>&gt;=</code> operator at least twice
testString: 'assert(code.match(/val\s*>=\s*(''|")*\d+(''|")*/g).length > 1, ''You should use the <code>&gt;=</code> operator at least twice'');'
testString: 'assert(code.match(/val\s*>=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&gt;=</code> operator at least twice");'
```
@@ -53,7 +53,7 @@ function testGreaterOrEqual(val) {
if (val) { // Change this line
return "20 or Over";
}
if (val) { // Change this line
return "10 or Over";
}
@@ -80,7 +80,7 @@ function testGreaterOrEqual(val) {
if (val >= 20) { // Change this line
return "20 or Over";
}
if (val >= 10) { // Change this line
return "10 or Over";
}

View File

@@ -22,17 +22,17 @@ Add the inequality operator <code>!=</code> in the <code>if</code> statement so
```yml
tests:
- text: <code>testNotEqual(99)</code> should return "Equal"
testString: 'assert(testNotEqual(99) === "Equal", ''<code>testNotEqual(99)</code> should return "Equal"'');'
testString: 'assert(testNotEqual(99) === "Equal", "<code>testNotEqual(99)</code> should return "Equal"");'
- text: <code>testNotEqual("99")</code> should return "Equal"
testString: 'assert(testNotEqual("99") === "Equal", ''<code>testNotEqual("99")</code> should return "Equal"'');'
testString: 'assert(testNotEqual("99") === "Equal", "<code>testNotEqual("99")</code> should return "Equal"");'
- text: <code>testNotEqual(12)</code> should return "Not Equal"
testString: 'assert(testNotEqual(12) === "Not Equal", ''<code>testNotEqual(12)</code> should return "Not Equal"'');'
testString: 'assert(testNotEqual(12) === "Not Equal", "<code>testNotEqual(12)</code> should return "Not Equal"");'
- text: <code>testNotEqual("12")</code> should return "Not Equal"
testString: 'assert(testNotEqual("12") === "Not Equal", ''<code>testNotEqual("12")</code> should return "Not Equal"'');'
testString: 'assert(testNotEqual("12") === "Not Equal", "<code>testNotEqual("12")</code> should return "Not Equal"");'
- text: <code>testNotEqual("bob")</code> should return "Not Equal"
testString: 'assert(testNotEqual("bob") === "Not Equal", ''<code>testNotEqual("bob")</code> should return "Not Equal"'');'
testString: 'assert(testNotEqual("bob") === "Not Equal", "<code>testNotEqual("bob")</code> should return "Not Equal"");'
- text: You should use the <code>!=</code> operator
testString: 'assert(code.match(/(?!!==)!=/), ''You should use the <code>!=</code> operator'');'
testString: 'assert(code.match(/(?!!==)!=/), "You should use the <code>!=</code> operator");'
```

View File

@@ -22,19 +22,19 @@ Add the <code>less than</code> operator to the indicated lines so that the retur
```yml
tests:
- text: <code>testLessThan(0)</code> should return "Under 25"
testString: 'assert(testLessThan(0) === "Under 25", ''<code>testLessThan(0)</code> should return "Under 25"'');'
testString: 'assert(testLessThan(0) === "Under 25", "<code>testLessThan(0)</code> should return "Under 25"");'
- text: <code>testLessThan(24)</code> should return "Under 25"
testString: 'assert(testLessThan(24) === "Under 25", ''<code>testLessThan(24)</code> should return "Under 25"'');'
testString: 'assert(testLessThan(24) === "Under 25", "<code>testLessThan(24)</code> should return "Under 25"");'
- text: <code>testLessThan(25)</code> should return "Under 55"
testString: 'assert(testLessThan(25) === "Under 55", ''<code>testLessThan(25)</code> should return "Under 55"'');'
testString: 'assert(testLessThan(25) === "Under 55", "<code>testLessThan(25)</code> should return "Under 55"");'
- text: <code>testLessThan(54)</code> should return "Under 55"
testString: 'assert(testLessThan(54) === "Under 55", ''<code>testLessThan(54)</code> should return "Under 55"'');'
testString: 'assert(testLessThan(54) === "Under 55", "<code>testLessThan(54)</code> should return "Under 55"");'
- text: <code>testLessThan(55)</code> should return "55 or Over"
testString: 'assert(testLessThan(55) === "55 or Over", ''<code>testLessThan(55)</code> should return "55 or Over"'');'
testString: 'assert(testLessThan(55) === "55 or Over", "<code>testLessThan(55)</code> should return "55 or Over"");'
- text: <code>testLessThan(99)</code> should return "55 or Over"
testString: 'assert(testLessThan(99) === "55 or Over", ''<code>testLessThan(99)</code> should return "55 or Over"'');'
testString: 'assert(testLessThan(99) === "55 or Over", "<code>testLessThan(99)</code> should return "55 or Over"");'
- text: You should use the <code>&lt;</code> operator at least twice
testString: 'assert(code.match(/val\s*<\s*(''|")*\d+(''|")*/g).length > 1, ''You should use the <code>&lt;</code> operator at least twice'');'
testString: 'assert(code.match(/val\s*<\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&lt;</code> operator at least twice");'
```
@@ -50,7 +50,7 @@ function testLessThan(val) {
if (val) { // Change this line
return "Under 25";
}
if (val) { // Change this line
return "Under 55";
}
@@ -77,7 +77,7 @@ function testLessThan(val) {
if (val < 25) { // Change this line
return "Under 25";
}
if (val < 55) { // Change this line
return "Under 55";
}

View File

@@ -22,21 +22,21 @@ Add the <code>less than or equal to</code> operator to the indicated lines so th
```yml
tests:
- text: <code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"
testString: 'assert(testLessOrEqual(0) === "Smaller Than or Equal to 12", ''<code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"'');'
testString: 'assert(testLessOrEqual(0) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"");'
- text: <code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"
testString: 'assert(testLessOrEqual(11) === "Smaller Than or Equal to 12", ''<code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"'');'
testString: 'assert(testLessOrEqual(11) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"");'
- text: <code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"
testString: 'assert(testLessOrEqual(12) === "Smaller Than or Equal to 12", ''<code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"'');'
testString: 'assert(testLessOrEqual(12) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"");'
- text: <code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"
testString: 'assert(testLessOrEqual(23) === "Smaller Than or Equal to 24", ''<code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"'');'
testString: 'assert(testLessOrEqual(23) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"");'
- text: <code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"
testString: 'assert(testLessOrEqual(24) === "Smaller Than or Equal to 24", ''<code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"'');'
testString: 'assert(testLessOrEqual(24) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"");'
- text: <code>testLessOrEqual(25)</code> should return "More Than 24"
testString: 'assert(testLessOrEqual(25) === "More Than 24", ''<code>testLessOrEqual(25)</code> should return "More Than 24"'');'
testString: 'assert(testLessOrEqual(25) === "More Than 24", "<code>testLessOrEqual(25)</code> should return "More Than 24"");'
- text: <code>testLessOrEqual(55)</code> should return "More Than 24"
testString: 'assert(testLessOrEqual(55) === "More Than 24", ''<code>testLessOrEqual(55)</code> should return "More Than 24"'');'
testString: 'assert(testLessOrEqual(55) === "More Than 24", "<code>testLessOrEqual(55)</code> should return "More Than 24"");'
- text: You should use the <code>&lt;=</code> operator at least twice
testString: 'assert(code.match(/val\s*<=\s*(''|")*\d+(''|")*/g).length > 1, ''You should use the <code>&lt;=</code> operator at least twice'');'
testString: 'assert(code.match(/val\s*<=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&lt;=</code> operator at least twice");'
```
@@ -52,7 +52,7 @@ function testLessOrEqual(val) {
if (val) { // Change this line
return "Smaller Than or Equal to 12";
}
if (val) { // Change this line
return "Smaller Than or Equal to 24";
}
@@ -80,7 +80,7 @@ function testLessOrEqual(val) {
if (val <= 12) { // Change this line
return "Smaller Than or Equal to 12";
}
if (val <= 24) { // Change this line
return "Smaller Than or Equal to 24";
}

View File

@@ -24,13 +24,13 @@ Use the strict equality operator in the <code>if</code> statement so the functio
```yml
tests:
- text: <code>testStrict(10)</code> should return "Not Equal"
testString: 'assert(testStrict(10) === "Not Equal", ''<code>testStrict(10)</code> should return "Not Equal"'');'
testString: 'assert(testStrict(10) === "Not Equal", "<code>testStrict(10)</code> should return "Not Equal"");'
- text: <code>testStrict(7)</code> should return "Equal"
testString: 'assert(testStrict(7) === "Equal", ''<code>testStrict(7)</code> should return "Equal"'');'
testString: 'assert(testStrict(7) === "Equal", "<code>testStrict(7)</code> should return "Equal"");'
- text: <code>testStrict("7")</code> should return "Not Equal"
testString: 'assert(testStrict("7") === "Not Equal", ''<code>testStrict("7")</code> should return "Not Equal"'');'
testString: 'assert(testStrict("7") === "Not Equal", "<code>testStrict("7")</code> should return "Not Equal"");'
- text: You should use the <code>===</code> operator
testString: 'assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0, ''You should use the <code>===</code> operator'');'
testString: 'assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0, "You should use the <code>===</code> operator");'
```

View File

@@ -22,15 +22,15 @@ Add the <code>strict inequality operator</code> to the <code>if</code> statement
```yml
tests:
- text: <code>testStrictNotEqual(17)</code> should return "Equal"
testString: 'assert(testStrictNotEqual(17) === "Equal", ''<code>testStrictNotEqual(17)</code> should return "Equal"'');'
testString: 'assert(testStrictNotEqual(17) === "Equal", "<code>testStrictNotEqual(17)</code> should return "Equal"");'
- text: <code>testStrictNotEqual("17")</code> should return "Not Equal"
testString: 'assert(testStrictNotEqual("17") === "Not Equal", ''<code>testStrictNotEqual("17")</code> should return "Not Equal"'');'
testString: 'assert(testStrictNotEqual("17") === "Not Equal", "<code>testStrictNotEqual("17")</code> should return "Not Equal"");'
- text: <code>testStrictNotEqual(12)</code> should return "Not Equal"
testString: 'assert(testStrictNotEqual(12) === "Not Equal", ''<code>testStrictNotEqual(12)</code> should return "Not Equal"'');'
testString: 'assert(testStrictNotEqual(12) === "Not Equal", "<code>testStrictNotEqual(12)</code> should return "Not Equal"");'
- text: <code>testStrictNotEqual("bob")</code> should return "Not Equal"
testString: 'assert(testStrictNotEqual("bob") === "Not Equal", ''<code>testStrictNotEqual("bob")</code> should return "Not Equal"'');'
testString: 'assert(testStrictNotEqual("bob") === "Not Equal", "<code>testStrictNotEqual("bob")</code> should return "Not Equal"");'
- text: You should use the <code>!==</code> operator
testString: 'assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0, ''You should use the <code>!==</code> operator'');'
testString: 'assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0, "You should use the <code>!==</code> operator");'
```
@@ -45,7 +45,7 @@ tests:
// Setup
function testStrictNotEqual(val) {
// Only Change Code Below this Line
if (val) {
// Only Change Code Above this Line

View File

@@ -24,25 +24,25 @@ Combine the two if statements into one statement which will return <code>"Yes"</
```yml
tests:
- text: You should use the <code>&&</code> operator once
testString: 'assert(code.match(/&&/g).length === 1, ''You should use the <code>&&</code> operator once'');'
testString: 'assert(code.match(/&&/g).length === 1, "You should use the <code>&&</code> operator once");'
- text: You should only have one <code>if</code> statement
testString: 'assert(code.match(/if/g).length === 1, ''You should only have one <code>if</code> statement'');'
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
- text: <code>testLogicalAnd(0)</code> should return "No"
testString: 'assert(testLogicalAnd(0) === "No", ''<code>testLogicalAnd(0)</code> should return "No"'');'
testString: 'assert(testLogicalAnd(0) === "No", "<code>testLogicalAnd(0)</code> should return "No"");'
- text: <code>testLogicalAnd(24)</code> should return "No"
testString: 'assert(testLogicalAnd(24) === "No", ''<code>testLogicalAnd(24)</code> should return "No"'');'
testString: 'assert(testLogicalAnd(24) === "No", "<code>testLogicalAnd(24)</code> should return "No"");'
- text: <code>testLogicalAnd(25)</code> should return "Yes"
testString: 'assert(testLogicalAnd(25) === "Yes", ''<code>testLogicalAnd(25)</code> should return "Yes"'');'
testString: 'assert(testLogicalAnd(25) === "Yes", "<code>testLogicalAnd(25)</code> should return "Yes"");'
- text: <code>testLogicalAnd(30)</code> should return "Yes"
testString: 'assert(testLogicalAnd(30) === "Yes", ''<code>testLogicalAnd(30)</code> should return "Yes"'');'
testString: 'assert(testLogicalAnd(30) === "Yes", "<code>testLogicalAnd(30)</code> should return "Yes"");'
- text: <code>testLogicalAnd(50)</code> should return "Yes"
testString: 'assert(testLogicalAnd(50) === "Yes", ''<code>testLogicalAnd(50)</code> should return "Yes"'');'
testString: 'assert(testLogicalAnd(50) === "Yes", "<code>testLogicalAnd(50)</code> should return "Yes"");'
- text: <code>testLogicalAnd(51)</code> should return "No"
testString: 'assert(testLogicalAnd(51) === "No", ''<code>testLogicalAnd(51)</code> should return "No"'');'
testString: 'assert(testLogicalAnd(51) === "No", "<code>testLogicalAnd(51)</code> should return "No"");'
- text: <code>testLogicalAnd(75)</code> should return "No"
testString: 'assert(testLogicalAnd(75) === "No", ''<code>testLogicalAnd(75)</code> should return "No"'');'
testString: 'assert(testLogicalAnd(75) === "No", "<code>testLogicalAnd(75)</code> should return "No"");'
- text: <code>testLogicalAnd(80)</code> should return "No"
testString: 'assert(testLogicalAnd(80) === "No", ''<code>testLogicalAnd(80)</code> should return "No"'');'
testString: 'assert(testLogicalAnd(80) === "No", "<code>testLogicalAnd(80)</code> should return "No"");'
```

View File

@@ -25,25 +25,25 @@ Combine the two <code>if</code> statements into one statement which returns <cod
```yml
tests:
- text: You should use the <code>||</code> operator once
testString: 'assert(code.match(/\|\|/g).length === 1, ''You should use the <code>||</code> operator once'');'
testString: 'assert(code.match(/\|\|/g).length === 1, "You should use the <code>||</code> operator once");'
- text: You should only have one <code>if</code> statement
testString: 'assert(code.match(/if/g).length === 1, ''You should only have one <code>if</code> statement'');'
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
- text: <code>testLogicalOr(0)</code> should return "Outside"
testString: 'assert(testLogicalOr(0) === "Outside", ''<code>testLogicalOr(0)</code> should return "Outside"'');'
testString: 'assert(testLogicalOr(0) === "Outside", "<code>testLogicalOr(0)</code> should return "Outside"");'
- text: <code>testLogicalOr(9)</code> should return "Outside"
testString: 'assert(testLogicalOr(9) === "Outside", ''<code>testLogicalOr(9)</code> should return "Outside"'');'
testString: 'assert(testLogicalOr(9) === "Outside", "<code>testLogicalOr(9)</code> should return "Outside"");'
- text: <code>testLogicalOr(10)</code> should return "Inside"
testString: 'assert(testLogicalOr(10) === "Inside", ''<code>testLogicalOr(10)</code> should return "Inside"'');'
testString: 'assert(testLogicalOr(10) === "Inside", "<code>testLogicalOr(10)</code> should return "Inside"");'
- text: <code>testLogicalOr(15)</code> should return "Inside"
testString: 'assert(testLogicalOr(15) === "Inside", ''<code>testLogicalOr(15)</code> should return "Inside"'');'
testString: 'assert(testLogicalOr(15) === "Inside", "<code>testLogicalOr(15)</code> should return "Inside"");'
- text: <code>testLogicalOr(19)</code> should return "Inside"
testString: 'assert(testLogicalOr(19) === "Inside", ''<code>testLogicalOr(19)</code> should return "Inside"'');'
testString: 'assert(testLogicalOr(19) === "Inside", "<code>testLogicalOr(19)</code> should return "Inside"");'
- text: <code>testLogicalOr(20)</code> should return "Inside"
testString: 'assert(testLogicalOr(20) === "Inside", ''<code>testLogicalOr(20)</code> should return "Inside"'');'
testString: 'assert(testLogicalOr(20) === "Inside", "<code>testLogicalOr(20)</code> should return "Inside"");'
- text: <code>testLogicalOr(21)</code> should return "Outside"
testString: 'assert(testLogicalOr(21) === "Outside", ''<code>testLogicalOr(21)</code> should return "Outside"'');'
testString: 'assert(testLogicalOr(21) === "Outside", "<code>testLogicalOr(21)</code> should return "Outside"");'
- text: <code>testLogicalOr(25)</code> should return "Outside"
testString: 'assert(testLogicalOr(25) === "Outside", ''<code>testLogicalOr(25)</code> should return "Outside"'');'
testString: 'assert(testLogicalOr(25) === "Outside", "<code>testLogicalOr(25)</code> should return "Outside"");'
```

View File

@@ -24,15 +24,15 @@ Convert the assignments for <code>a</code>, <code>b</code>, and <code>c</code> t
```yml
tests:
- text: <code>a</code> should equal <code>15</code>
testString: 'assert(a === 15, ''<code>a</code> should equal <code>15</code>'');'
testString: 'assert(a === 15, "<code>a</code> should equal <code>15</code>");'
- text: <code>b</code> should equal <code>26</code>
testString: 'assert(b === 26, ''<code>b</code> should equal <code>26</code>'');'
testString: 'assert(b === 26, "<code>b</code> should equal <code>26</code>");'
- text: <code>c</code> should equal <code>19</code>
testString: 'assert(c === 19, ''<code>c</code> should equal <code>19</code>'');'
testString: 'assert(c === 19, "<code>c</code> should equal <code>19</code>");'
- text: You should use the <code>+=</code> operator for each variable
testString: 'assert(code.match(/\+=/g).length === 3, ''You should use the <code>+=</code> operator for each variable'');'
testString: 'assert(code.match(/\+=/g).length === 3, "You should use the <code>+=</code> operator for each variable");'
- text: Do not modify the code above the line
testString: 'assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code), ''Do not modify the code above the line'');'
testString: 'assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code), "Do not modify the code above the line");'
```

View File

@@ -8,7 +8,7 @@ challengeType: 1
<section id='description'>
The <code>/=</code> operator divides a variable by another number.
<code>myVar = myVar / 5;</code>
Will divide <code>myVar</code> by <code>5</code>. This can be rewritten as:
Will divide <code>myVar</code> by <code>5</code>. This can be rewritten as:
<code>myVar /= 5;</code>
</section>
@@ -23,15 +23,15 @@ Convert the assignments for <code>a</code>, <code>b</code>, and <code>c</code> t
```yml
tests:
- text: <code>a</code> should equal <code>4</code>
testString: 'assert(a === 4, ''<code>a</code> should equal <code>4</code>'');'
testString: 'assert(a === 4, "<code>a</code> should equal <code>4</code>");'
- text: <code>b</code> should equal <code>27</code>
testString: 'assert(b === 27, ''<code>b</code> should equal <code>27</code>'');'
testString: 'assert(b === 27, "<code>b</code> should equal <code>27</code>");'
- text: <code>c</code> should equal <code>3</code>
testString: 'assert(c === 3, ''<code>c</code> should equal <code>3</code>'');'
testString: 'assert(c === 3, "<code>c</code> should equal <code>3</code>");'
- text: You should use the <code>/=</code> operator for each variable
testString: 'assert(code.match(/\/=/g).length === 3, ''You should use the <code>/=</code> operator for each variable'');'
testString: 'assert(code.match(/\/=/g).length === 3, "You should use the <code>/=</code> operator for each variable");'
- text: Do not modify the code above the line
testString: 'assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code), ''Do not modify the code above the line'');'
testString: 'assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code), "Do not modify the code above the line");'
```

View File

@@ -8,7 +8,7 @@ challengeType: 1
<section id='description'>
The <code>*=</code> operator multiplies a variable by a number.
<code>myVar = myVar * 5;</code>
will multiply <code>myVar</code> by <code>5</code>. This can be rewritten as:
will multiply <code>myVar</code> by <code>5</code>. This can be rewritten as:
<code>myVar *= 5;</code>
</section>
@@ -23,15 +23,15 @@ Convert the assignments for <code>a</code>, <code>b</code>, and <code>c</code> t
```yml
tests:
- text: <code>a</code> should equal <code>25</code>
testString: 'assert(a === 25, ''<code>a</code> should equal <code>25</code>'');'
testString: 'assert(a === 25, "<code>a</code> should equal <code>25</code>");'
- text: <code>b</code> should equal <code>36</code>
testString: 'assert(b === 36, ''<code>b</code> should equal <code>36</code>'');'
testString: 'assert(b === 36, "<code>b</code> should equal <code>36</code>");'
- text: <code>c</code> should equal <code>46</code>
testString: 'assert(c === 46, ''<code>c</code> should equal <code>46</code>'');'
testString: 'assert(c === 46, "<code>c</code> should equal <code>46</code>");'
- text: You should use the <code>*=</code> operator for each variable
testString: 'assert(code.match(/\*=/g).length === 3, ''You should use the <code>*=</code> operator for each variable'');'
testString: 'assert(code.match(/\*=/g).length === 3, "You should use the <code>*=</code> operator for each variable");'
- text: Do not modify the code above the line
testString: 'assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\.6;/.test(code), ''Do not modify the code above the line'');'
testString: 'assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\.6;/.test(code), "Do not modify the code above the line");'
```

View File

@@ -8,7 +8,7 @@ challengeType: 1
<section id='description'>
Like the <code>+=</code> operator, <code>-=</code> subtracts a number from a variable.
<code>myVar = myVar - 5;</code>
will subtract <code>5</code> from <code>myVar</code>. This can be rewritten as:
will subtract <code>5</code> from <code>myVar</code>. This can be rewritten as:
<code>myVar -= 5;</code>
</section>
@@ -23,15 +23,15 @@ Convert the assignments for <code>a</code>, <code>b</code>, and <code>c</code> t
```yml
tests:
- text: <code>a</code> should equal <code>5</code>
testString: 'assert(a === 5, ''<code>a</code> should equal <code>5</code>'');'
testString: 'assert(a === 5, "<code>a</code> should equal <code>5</code>");'
- text: <code>b</code> should equal <code>-6</code>
testString: 'assert(b === -6, ''<code>b</code> should equal <code>-6</code>'');'
testString: 'assert(b === -6, "<code>b</code> should equal <code>-6</code>");'
- text: <code>c</code> should equal <code>2</code>
testString: 'assert(c === 2, ''<code>c</code> should equal <code>2</code>'');'
testString: 'assert(c === 2, "<code>c</code> should equal <code>2</code>");'
- text: You should use the <code>-=</code> operator for each variable
testString: 'assert(code.match(/-=/g).length === 3, ''You should use the <code>-=</code> operator for each variable'');'
testString: 'assert(code.match(/-=/g).length === 3, "You should use the <code>-=</code> operator for each variable");'
- text: Do not modify the code above the line
testString: 'assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code), ''Do not modify the code above the line'');'
testString: 'assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code), "Do not modify the code above the line");'
```

View File

@@ -23,13 +23,13 @@ Build <code>myStr</code> from the strings <code>"This is the start. "</code> and
```yml
tests:
- text: <code>myStr</code> should have a value of <code>This is the start. This is the end.</code>
testString: 'assert(myStr === "This is the start. This is the end.", ''<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>'');'
testString: 'assert(myStr === "This is the start. This is the end.", "<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>");'
- text: Use the <code>+</code> operator to build <code>myStr</code>
testString: 'assert(code.match(/(["'']).*(["''])\s*\+\s*(["'']).*(["''])/g).length > 1, ''Use the <code>+</code> operator to build <code>myStr</code>'');'
testString: 'assert(code.match(/([""]).*([""])\s*\+\s*([""]).*([""])/g).length > 1, "Use the <code>+</code> operator to build <code>myStr</code>");'
- text: <code>myStr</code> should be created using the <code>var</code> keyword.
testString: 'assert(/var\s+myStr/.test(code), ''<code>myStr</code> should be created using the <code>var</code> keyword.'');'
testString: 'assert(/var\s+myStr/.test(code), "<code>myStr</code> should be created using the <code>var</code> keyword.");'
- text: Make sure to assign the result to the <code>myStr</code> variable.
testString: 'assert(/myStr\s*=/.test(code), ''Make sure to assign the result to the <code>myStr</code> variable.'');'
testString: 'assert(/myStr\s*=/.test(code), "Make sure to assign the result to the <code>myStr</code> variable.");'
```

View File

@@ -21,9 +21,9 @@ Build <code>myStr</code> over several lines by concatenating these two strings:
```yml
tests:
- text: <code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", ''<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>'');'
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", "<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>");'
- text: Use the <code>+=</code> operator to build <code>myStr</code>
testString: 'assert(code.match(/\w\s*\+=\s*["'']/g).length > 1 && code.match(/\w\s*\=\s*["'']/g).length > 1, ''Use the <code>+=</code> operator to build <code>myStr</code>'');'
testString: 'assert(code.match(/\w\s*\+=\s*[""]/g).length > 1 && code.match(/\w\s*\=\s*[""]/g).length > 1, "Use the <code>+=</code> operator to build <code>myStr</code>");'
```

View File

@@ -20,9 +20,9 @@ Set <code>myName</code> to a string equal to your name and build <code>myStr</co
```yml
tests:
- text: <code>myName</code> should be set to a string at least 3 characters long
testString: 'assert(typeof myName !== ''undefined'' && myName.length > 2, ''<code>myName</code> should be set to a string at least 3 characters long'');'
testString: 'assert(typeof myName !== "undefined" && myName.length > 2, "<code>myName</code> should be set to a string at least 3 characters long");'
- text: Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it
testString: 'assert(code.match(/["'']\s*\+\s*myName\s*\+\s*["'']/g).length > 0, ''Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it'');'
testString: 'assert(code.match(/[""]\s*\+\s*myName\s*\+\s*[""]/g).length > 0, "Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it");'
```

View File

@@ -25,11 +25,11 @@ Push the odd numbers from 9 through 1 to <code>myArray</code> using a <code>for<
```yml
tests:
- text: You should be using a <code>for</code> loop for this.
testString: 'assert(code.match(/for\s*\(/g).length > 1, ''You should be using a <code>for</code> loop for this.'');'
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
- text: You should be using the array method <code>push</code>.
testString: 'assert(code.match(/myArray.push/), ''You should be using the array method <code>push</code>.'');'
testString: 'assert(code.match(/myArray.push/), "You should be using the array method <code>push</code>.");'
- text: '<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.'
testString: 'assert.deepEqual(myArray, [9,7,5,3,1], ''<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.'');'
testString: 'assert.deepEqual(myArray, [9,7,5,3,1], "<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.");'
```

View File

@@ -25,19 +25,19 @@ You will write a card counting function. It will receive a <code>card</code> par
```yml
tests:
- text: 'Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>'
testString: 'assert((function(){ count = 0; cc(2);cc(3);cc(4);cc(5);var out = cc(6); if(out === "5 Bet") {return true;} return false; })(), ''Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>'');'
testString: 'assert((function(){ count = 0; cc(2);cc(3);cc(4);cc(5);var out = cc(6); if(out === "5 Bet") {return true;} return false; })(), "Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>");'
- text: 'Cards Sequence 7, 8, 9 should return <code>0 Hold</code>'
testString: 'assert((function(){ count = 0; cc(7);cc(8);var out = cc(9); if(out === "0 Hold") {return true;} return false; })(), ''Cards Sequence 7, 8, 9 should return <code>0 Hold</code>'');'
testString: 'assert((function(){ count = 0; cc(7);cc(8);var out = cc(9); if(out === "0 Hold") {return true;} return false; })(), "Cards Sequence 7, 8, 9 should return <code>0 Hold</code>");'
- text: 'Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>'
testString: 'assert((function(){ count = 0; cc(10);cc(''J'');cc(''Q'');cc(''K'');var out = cc(''A''); if(out === "-5 Hold") {return true;} return false; })(), ''Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>'');'
testString: 'assert((function(){ count = 0; cc(10);cc("J");cc("Q");cc("K");var out = cc("A"); if(out === "-5 Hold") {return true;} return false; })(), "Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>");'
- text: 'Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>'
testString: 'assert((function(){ count = 0; cc(3);cc(7);cc(''Q'');cc(8);var out = cc(''A''); if(out === "-1 Hold") {return true;} return false; })(), ''Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>'');'
testString: 'assert((function(){ count = 0; cc(3);cc(7);cc("Q");cc(8);var out = cc("A"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>");'
- text: 'Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>'
testString: 'assert((function(){ count = 0; cc(2);cc(''J'');cc(9);cc(2);var out = cc(7); if(out === "1 Bet") {return true;} return false; })(), ''Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>'');'
testString: 'assert((function(){ count = 0; cc(2);cc("J");cc(9);cc(2);var out = cc(7); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>");'
- text: 'Cards Sequence 2, 2, 10 should return <code>1 Bet</code>'
testString: 'assert((function(){ count = 0; cc(2);cc(2);var out = cc(10); if(out === "1 Bet") {return true;} return false; })(), ''Cards Sequence 2, 2, 10 should return <code>1 Bet</code>'');'
testString: 'assert((function(){ count = 0; cc(2);cc(2);var out = cc(10); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, 2, 10 should return <code>1 Bet</code>");'
- text: 'Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>'
testString: 'assert((function(){ count = 0; cc(3);cc(2);cc(''A'');cc(10);var out = cc(''K''); if(out === "-1 Hold") {return true;} return false; })(), ''Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>'');'
testString: 'assert((function(){ count = 0; cc(3);cc(2);cc("A");cc(10);var out = cc("K"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>");'
```
@@ -53,8 +53,8 @@ var count = 0;
function cc(card) {
// Only change code below this line
return "Change Me";
// Only change code above this line
}

View File

@@ -21,9 +21,9 @@ Create a variable <code>myDecimal</code> and give it a decimal value with a frac
```yml
tests:
- text: <code>myDecimal</code> should be a number.
testString: 'assert(typeof myDecimal === "number", ''<code>myDecimal</code> should be a number.'');'
testString: 'assert(typeof myDecimal === "number", "<code>myDecimal</code> should be a number.");'
- text: <code>myDecimal</code> should have a decimal point
testString: 'assert(myDecimal % 1 != 0, ''<code>myDecimal</code> should have a decimal point''); '
testString: 'assert(myDecimal % 1 != 0, "<code>myDecimal</code> should have a decimal point"); '
```

View File

@@ -28,7 +28,7 @@ Use the <code>var</code> keyword to create a variable called <code>myName</code>
```yml
tests:
- text: 'You should declare <code>myName</code> with the <code>var</code> keyword, ending with a semicolon'
testString: 'assert(/var\s+myName\s*;/.test(code), ''You should declare <code>myName</code> with the <code>var</code> keyword, ending with a semicolon'');'
testString: 'assert(/var\s+myName\s*;/.test(code), "You should declare <code>myName</code> with the <code>var</code> keyword, ending with a semicolon");'
```

View File

@@ -22,9 +22,9 @@ Create two new <code>string</code> variables: <code>myFirstName</code> and <code
```yml
tests:
- text: <code>myFirstName</code> should be a string with at least one character in it.
testString: 'assert((function(){if(typeof myFirstName !== "undefined" && typeof myFirstName === "string" && myFirstName.length > 0){return true;}else{return false;}})(), ''<code>myFirstName</code> should be a string with at least one character in it.'');'
testString: 'assert((function(){if(typeof myFirstName !== "undefined" && typeof myFirstName === "string" && myFirstName.length > 0){return true;}else{return false;}})(), "<code>myFirstName</code> should be a string with at least one character in it.");'
- text: <code>myLastName</code> should be a string with at least one character in it.
testString: 'assert((function(){if(typeof myLastName !== "undefined" && typeof myLastName === "string" && myLastName.length > 0){return true;}else{return false;}})(), ''<code>myLastName</code> should be a string with at least one character in it.'');'
testString: 'assert((function(){if(typeof myLastName !== "undefined" && typeof myLastName === "string" && myLastName.length > 0){return true;}else{return false;}})(), "<code>myLastName</code> should be a string with at least one character in it.");'
```

View File

@@ -24,13 +24,13 @@ Change the code to use the <code>--</code> operator on <code>myVar</code>.
```yml
tests:
- text: <code>myVar</code> should equal <code>10</code>
testString: 'assert(myVar === 10, ''<code>myVar</code> should equal <code>10</code>'');'
testString: 'assert(myVar === 10, "<code>myVar</code> should equal <code>10</code>");'
- text: <code>myVar = myVar - 1;</code> should be changed
testString: 'assert(/var\s*myVar\s*=\s*11;\s*\/*.*\s*([-]{2}\s*myVar|myVar\s*[-]{2});/.test(code), ''<code>myVar = myVar - 1;</code> should be changed'');'
testString: 'assert(/var\s*myVar\s*=\s*11;\s*\/*.*\s*([-]{2}\s*myVar|myVar\s*[-]{2});/.test(code), "<code>myVar = myVar - 1;</code> should be changed");'
- text: Use the <code>--</code> operator on <code>myVar</code>
testString: 'assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code), ''Use the <code>--</code> operator on <code>myVar</code>'');'
testString: 'assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code), "Use the <code>--</code> operator on <code>myVar</code>");'
- text: Do not change code above the line
testString: 'assert(/var myVar = 11;/.test(code), ''Do not change code above the line'');'
testString: 'assert(/var myVar = 11;/.test(code), "Do not change code above the line");'
```

View File

@@ -21,9 +21,9 @@ Delete the <code>"tails"</code> property from <code>myDog</code>. You may use ei
```yml
tests:
- text: Delete the property <code>"tails"</code> from <code>myDog</code>.
testString: 'assert(typeof myDog === "object" && myDog.tails === undefined, ''Delete the property <code>"tails"</code> from <code>myDog</code>.'');'
testString: 'assert(typeof myDog === "object" && myDog.tails === undefined, "Delete the property <code>"tails"</code> from <code>myDog</code>.");'
- text: Do not modify the <code>myDog</code> setup
testString: 'assert(code.match(/"tails": 1/g).length > 1, ''Do not modify the <code>myDog</code> setup'');'
testString: 'assert(code.match(/"tails": 1/g).length > 1, "Do not modify the <code>myDog</code> setup");'
```

View File

@@ -20,11 +20,11 @@ Change the <code>0.0</code> so that <code>quotient</code> will equal to <code>2.
```yml
tests:
- text: The variable <code>quotient</code> should equal <code>2.2</code>
testString: 'assert(quotient === 2.2, ''The variable <code>quotient</code> should equal <code>2.2</code>'');'
testString: 'assert(quotient === 2.2, "The variable <code>quotient</code> should equal <code>2.2</code>");'
- text: You should use the <code>/</code> operator to divide 4.4 by 2
testString: 'assert(/4\.40*\s*\/\s*2\.*0*/.test(code), ''You should use the <code>/</code> operator to divide 4.4 by 2'');'
testString: 'assert(/4\.40*\s*\/\s*2\.*0*/.test(code), "You should use the <code>/</code> operator to divide 4.4 by 2");'
- text: The quotient variable should only be assigned once
testString: 'assert(code.match(/quotient/g).length === 1, ''The quotient variable should only be assigned once'');'
testString: 'assert(code.match(/quotient/g).length === 1, "The quotient variable should only be assigned once");'
```

View File

@@ -25,9 +25,9 @@ Change the <code>0</code> so that the <code>quotient</code> is equal to <code>2<
```yml
tests:
- text: Make the variable <code>quotient</code> equal to 2.
testString: 'assert(quotient === 2, ''Make the variable <code>quotient</code> equal to 2.'');'
testString: 'assert(quotient === 2, "Make the variable <code>quotient</code> equal to 2.");'
- text: Use the <code>/</code> operator
testString: 'assert(/\d+\s*\/\s*\d+/.test(code), ''Use the <code>/</code> operator'');'
testString: 'assert(/\d+\s*\/\s*\d+/.test(code), "Use the <code>/</code> operator");'
```

View File

@@ -26,17 +26,17 @@ Here is the text with the escape sequences written out.
```yml
tests:
- text: <code>myStr</code> should not contain any spaces
testString: 'assert(!/ /.test(myStr), ''<code>myStr</code> should not contain any spaces'');'
testString: 'assert(!/ /.test(myStr), "<code>myStr</code> should not contain any spaces");'
- text: '<code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)'
testString: 'assert(/FirstLine/.test(myStr) && /SecondLine/.test(myStr) && /ThirdLine/.test(myStr), ''<code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)'');'
testString: 'assert(/FirstLine/.test(myStr) && /SecondLine/.test(myStr) && /ThirdLine/.test(myStr), "<code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)");'
- text: <code>FirstLine</code> should be followed by the newline character <code>\n</code>
testString: 'assert(/FirstLine\n/.test(myStr), ''<code>FirstLine</code> should be followed by the newline character <code>\n</code>'');'
testString: 'assert(/FirstLine\n/.test(myStr), "<code>FirstLine</code> should be followed by the newline character <code>\n</code>");'
- text: <code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character
testString: 'assert(/\n\t/.test(myStr), ''<code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character'');'
testString: 'assert(/\n\t/.test(myStr), "<code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character");'
- text: <code>SecondLine</code> should be preceded by the backslash character <code>\\</code>
testString: 'assert(/\SecondLine/.test(myStr), ''<code>SecondLine</code> should be preceded by the backslash character <code>\\</code>'');'
testString: 'assert(/\SecondLine/.test(myStr), "<code>SecondLine</code> should be preceded by the backslash character <code>\\</code>");'
- text: There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>
testString: 'assert(/SecondLine\nThirdLine/.test(myStr), ''There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>'');'
testString: 'assert(/SecondLine\nThirdLine/.test(myStr), "There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>");'
```

View File

@@ -25,9 +25,9 @@ Use <dfn>backslashes</dfn> to assign a string to the <code>myStr</code> variable
```yml
tests:
- text: 'You should use two double quotes (<code>&quot;</code>) and four escaped double quotes (<code>&#92;&quot;</code>).'
testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, ''You should use two double quotes (<code>&quot;</code>) and four escaped double quotes (<code>&#92;&quot;</code>).'');'
testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, "You should use two double quotes (<code>&quot;</code>) and four escaped double quotes (<code>&#92;&quot;</code>).");'
- text: 'Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>'
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".", ''Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>'');'
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".", "Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>");'
```

View File

@@ -22,9 +22,9 @@ Use the <code>.length</code> property to count the number of characters in the <
```yml
tests:
- text: <code>lastNameLength</code> should be equal to eight.
testString: 'assert((function(){if(typeof lastNameLength !== "undefined" && typeof lastNameLength === "number" && lastNameLength === 8){return true;}else{return false;}})(), ''<code>lastNameLength</code> should be equal to eight.'');'
testString: 'assert((function(){if(typeof lastNameLength !== "undefined" && typeof lastNameLength === "number" && lastNameLength === 8){return true;}else{return false;}})(), "<code>lastNameLength</code> should be equal to eight.");'
- text: 'You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.'
testString: '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;}})(), ''You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.'');'
testString: '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;}})(), "You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.");'
```

View File

@@ -25,11 +25,11 @@ Set <code>remainder</code> equal to the remainder of <code>11</code> divided by
```yml
tests:
- text: The variable <code>remainder</code> should be initialized
testString: 'assert(/var\s+?remainder/.test(code), ''The variable <code>remainder</code> should be initialized'');'
testString: 'assert(/var\s+?remainder/.test(code), "The variable <code>remainder</code> should be initialized");'
- text: The value of <code>remainder</code> should be <code>2</code>
testString: 'assert(remainder === 2, ''The value of <code>remainder</code> should be <code>2</code>'');'
testString: 'assert(remainder === 2, "The value of <code>remainder</code> should be <code>2</code>");'
- text: You should use the <code>%</code> operator
testString: 'assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code), ''You should use the <code>%</code> operator'');'
testString: 'assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code), "You should use the <code>%</code> operator");'
```

View File

@@ -22,11 +22,11 @@ Change <code>randomFraction</code> to return a random number instead of returnin
```yml
tests:
- text: <code>randomFraction</code> should return a random number.
testString: 'assert(typeof randomFraction() === "number", ''<code>randomFraction</code> should return a random number.'');'
testString: 'assert(typeof randomFraction() === "number", "<code>randomFraction</code> should return a random number.");'
- text: The number returned by <code>randomFraction</code> should be a decimal.
testString: 'assert((randomFraction()+''''). match(/\./g), ''The number returned by <code>randomFraction</code> should be a decimal.'');'
testString: 'assert((randomFraction()+""). match(/\./g), "The number returned by <code>randomFraction</code> should be a decimal.");'
- text: You should be using <code>Math.random</code> to generate the random decimal number.
testString: 'assert(code.match(/Math\.random/g).length >= 0, ''You should be using <code>Math.random</code> to generate the random decimal number.'');'
testString: 'assert(code.match(/Math\.random/g).length >= 0, "You should be using <code>Math.random</code> to generate the random decimal number.");'
```

View File

@@ -25,13 +25,13 @@ Use this technique to generate and return a random whole number between <code>0<
```yml
tests:
- text: The result of <code>randomWholeNum</code> should be a whole number.
testString: 'assert(typeof randomWholeNum() === "number" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), ''The result of <code>randomWholeNum</code> should be a whole number.'');'
testString: 'assert(typeof randomWholeNum() === "number" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), "The result of <code>randomWholeNum</code> should be a whole number.");'
- text: You should be using <code>Math.random</code> to generate a random number.
testString: 'assert(code.match(/Math.random/g).length > 1, ''You should be using <code>Math.random</code> to generate a random number.'');'
testString: 'assert(code.match(/Math.random/g).length > 1, "You should be using <code>Math.random</code> to generate a random number.");'
- text: You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.
testString: 'assert(code.match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) || code.match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g), ''You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.'');'
testString: 'assert(code.match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) || code.match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g), "You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.");'
- text: You should use <code>Math.floor</code> to remove the decimal part of the number.
testString: 'assert(code.match(/Math.floor/g).length > 1, ''You should use <code>Math.floor</code> to remove the decimal part of the number.'');'
testString: 'assert(code.match(/Math.floor/g).length > 1, "You should use <code>Math.floor</code> to remove the decimal part of the number.");'
```

View File

@@ -23,13 +23,13 @@ Create a function called <code>randomRange</code> that takes a range <code>myMin
```yml
tests:
- text: 'The lowest random number that can be generated by <code>randomRange</code> should be equal to your minimum number, <code>myMin</code>.'
testString: 'assert(calcMin === 5, ''The lowest random number that can be generated by <code>randomRange</code> should be equal to your minimum number, <code>myMin</code>.'');'
testString: 'assert(calcMin === 5, "The lowest random number that can be generated by <code>randomRange</code> should be equal to your minimum number, <code>myMin</code>.");'
- text: 'The highest random number that can be generated by <code>randomRange</code> should be equal to your maximum number, <code>myMax</code>.'
testString: 'assert(calcMax === 15, ''The highest random number that can be generated by <code>randomRange</code> should be equal to your maximum number, <code>myMax</code>.'');'
testString: 'assert(calcMax === 15, "The highest random number that can be generated by <code>randomRange</code> should be equal to your maximum number, <code>myMax</code>.");'
- text: 'The random number generated by <code>randomRange</code> should be an integer, not a decimal.'
testString: 'assert(randomRange(0,1) % 1 === 0 , ''The random number generated by <code>randomRange</code> should be an integer, not a decimal.'');'
testString: 'assert(randomRange(0,1) % 1 === 0 , "The random number generated by <code>randomRange</code> should be an integer, not a decimal.");'
- text: '<code>randomRange</code> should use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.'
testString: '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;}})(), ''<code>randomRange</code> should use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.'');'
testString: '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;}})(), "<code>randomRange</code> should use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.");'
```

View File

@@ -22,13 +22,13 @@ Inside function <code>fun1</code>, assign <code>5</code> to <code>oopsGlobal</co
```yml
tests:
- text: <code>myGlobal</code> should be defined
testString: 'assert(typeof myGlobal != "undefined", ''<code>myGlobal</code> should be defined'');'
testString: 'assert(typeof myGlobal != "undefined", "<code>myGlobal</code> should be defined");'
- text: <code>myGlobal</code> should have a value of <code>10</code>
testString: 'assert(myGlobal === 10, ''<code>myGlobal</code> should have a value of <code>10</code>'');'
testString: 'assert(myGlobal === 10, "<code>myGlobal</code> should have a value of <code>10</code>");'
- text: <code>myGlobal</code> should be declared using the <code>var</code> keyword
testString: 'assert(/var\s+myGlobal/.test(code), ''<code>myGlobal</code> should be declared using the <code>var</code> keyword'');'
testString: 'assert(/var\s+myGlobal/.test(code), "<code>myGlobal</code> should be declared using the <code>var</code> keyword");'
- text: <code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>
testString: 'assert(typeof oopsGlobal != "undefined" && oopsGlobal === 5, ''<code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>'');'
testString: 'assert(typeof oopsGlobal != "undefined" && oopsGlobal === 5, "<code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>");'
```
@@ -45,7 +45,7 @@ tests:
function fun1() {
// Assign 5 to oopsGlobal Here
}
// Only change code above this line

View File

@@ -23,11 +23,11 @@ Add a local variable to <code>myOutfit</code> function to override the value of
```yml
tests:
- text: Do not change the value of the global <code>outerWear</code>
testString: 'assert(outerWear === "T-Shirt", ''Do not change the value of the global <code>outerWear</code>'');'
testString: 'assert(outerWear === "T-Shirt", "Do not change the value of the global <code>outerWear</code>");'
- text: <code>myOutfit</code> should return <code>"sweater"</code>
testString: 'assert(myOutfit() === "sweater", ''<code>myOutfit</code> should return <code>"sweater"</code>'');'
testString: 'assert(myOutfit() === "sweater", "<code>myOutfit</code> should return <code>"sweater"</code>");'
- text: Do not change the return statement
testString: 'assert(/return outerWear/.test(code), ''Do not change the return statement'');'
testString: 'assert(/return outerWear/.test(code), "Do not change the return statement");'
```
@@ -44,9 +44,9 @@ var outerWear = "T-Shirt";
function myOutfit() {
// Only change code below this line
// Only change code above this line
return outerWear;
}

View File

@@ -23,27 +23,27 @@ Your function will be passed <code>par</code> and <code>strokes</code> arguments
```yml
tests:
- text: '<code>golfScore(4, 1)</code> should return "Hole-in-one!"'
testString: 'assert(golfScore(4, 1) === "Hole-in-one!", ''<code>golfScore(4, 1)</code> should return "Hole-in-one!"'');'
testString: 'assert(golfScore(4, 1) === "Hole-in-one!", "<code>golfScore(4, 1)</code> should return "Hole-in-one!"");'
- text: '<code>golfScore(4, 2)</code> should return "Eagle"'
testString: 'assert(golfScore(4, 2) === "Eagle", ''<code>golfScore(4, 2)</code> should return "Eagle"'');'
testString: 'assert(golfScore(4, 2) === "Eagle", "<code>golfScore(4, 2)</code> should return "Eagle"");'
- text: '<code>golfScore(5, 2)</code> should return "Eagle"'
testString: 'assert(golfScore(5, 2) === "Eagle", ''<code>golfScore(5, 2)</code> should return "Eagle"'');'
testString: 'assert(golfScore(5, 2) === "Eagle", "<code>golfScore(5, 2)</code> should return "Eagle"");'
- text: '<code>golfScore(4, 3)</code> should return "Birdie"'
testString: 'assert(golfScore(4, 3) === "Birdie", ''<code>golfScore(4, 3)</code> should return "Birdie"'');'
testString: 'assert(golfScore(4, 3) === "Birdie", "<code>golfScore(4, 3)</code> should return "Birdie"");'
- text: '<code>golfScore(4, 4)</code> should return "Par"'
testString: 'assert(golfScore(4, 4) === "Par", ''<code>golfScore(4, 4)</code> should return "Par"'');'
testString: 'assert(golfScore(4, 4) === "Par", "<code>golfScore(4, 4)</code> should return "Par"");'
- text: '<code>golfScore(1, 1)</code> should return "Hole-in-one!"'
testString: 'assert(golfScore(1, 1) === "Hole-in-one!", ''<code>golfScore(1, 1)</code> should return "Hole-in-one!"'');'
testString: 'assert(golfScore(1, 1) === "Hole-in-one!", "<code>golfScore(1, 1)</code> should return "Hole-in-one!"");'
- text: '<code>golfScore(5, 5)</code> should return "Par"'
testString: 'assert(golfScore(5, 5) === "Par", ''<code>golfScore(5, 5)</code> should return "Par"'');'
testString: 'assert(golfScore(5, 5) === "Par", "<code>golfScore(5, 5)</code> should return "Par"");'
- text: '<code>golfScore(4, 5)</code> should return "Bogey"'
testString: 'assert(golfScore(4, 5) === "Bogey", ''<code>golfScore(4, 5)</code> should return "Bogey"'');'
testString: 'assert(golfScore(4, 5) === "Bogey", "<code>golfScore(4, 5)</code> should return "Bogey"");'
- text: '<code>golfScore(4, 6)</code> should return "Double Bogey"'
testString: 'assert(golfScore(4, 6) === "Double Bogey", ''<code>golfScore(4, 6)</code> should return "Double Bogey"'');'
testString: 'assert(golfScore(4, 6) === "Double Bogey", "<code>golfScore(4, 6)</code> should return "Double Bogey"");'
- text: '<code>golfScore(4, 7)</code> should return "Go Home!"'
testString: 'assert(golfScore(4, 7) === "Go Home!", ''<code>golfScore(4, 7)</code> should return "Go Home!"'');'
testString: 'assert(golfScore(4, 7) === "Go Home!", "<code>golfScore(4, 7)</code> should return "Go Home!"");'
- text: '<code>golfScore(5, 9)</code> should return "Go Home!"'
testString: 'assert(golfScore(5, 9) === "Go Home!", ''<code>golfScore(5, 9)</code> should return "Go Home!"'');'
testString: 'assert(golfScore(5, 9) === "Go Home!", "<code>golfScore(5, 9)</code> should return "Go Home!"");'
```
@@ -58,8 +58,8 @@ tests:
var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
function golfScore(par, strokes) {
// Only change code below this line
return "Change Me";
// Only change code above this line
}
@@ -83,27 +83,27 @@ function golfScore(par, strokes) {
if (strokes === 1) {
return "Hole-in-one!";
}
if (strokes <= par - 2) {
return "Eagle";
}
if (strokes === par - 1) {
return "Birdie";
}
if (strokes === par) {
return "Par";
}
if (strokes === par + 1) {
return "Bogey";
}
if(strokes === par + 2) {
return "Double Bogey";
}
return "Go Home!";
}
```

View File

@@ -25,13 +25,13 @@ Change the code to use the <code>++</code> operator on <code>myVar</code>.
```yml
tests:
- text: <code>myVar</code> should equal <code>88</code>
testString: 'assert(myVar === 88, ''<code>myVar</code> should equal <code>88</code>'');'
testString: 'assert(myVar === 88, "<code>myVar</code> should equal <code>88</code>");'
- text: <code>myVar = myVar + 1;</code> should be changed
testString: 'assert(/var\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2});/.test(code), ''<code>myVar = myVar + 1;</code> should be changed'');'
testString: 'assert(/var\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2});/.test(code), "<code>myVar = myVar + 1;</code> should be changed");'
- text: Use the <code>++</code> operator
testString: 'assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code), ''Use the <code>++</code> operator'');'
testString: 'assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code), "Use the <code>++</code> operator");'
- text: Do not change code above the line
testString: 'assert(/var myVar = 87;/.test(code), ''Do not change code above the line'');'
testString: 'assert(/var myVar = 87;/.test(code), "Do not change code above the line");'
```

View File

@@ -22,7 +22,7 @@ Define a variable <code>a</code> with <code>var</code> and initialize it to a va
```yml
tests:
- text: Initialize <code>a</code> to a value of <code>9</code>
testString: 'assert(/var\s+a\s*=\s*9\s*/.test(code), ''Initialize <code>a</code> to a value of <code>9</code>'');'
testString: 'assert(/var\s+a\s*=\s*9\s*/.test(code), "Initialize <code>a</code> to a value of <code>9</code>");'
```

View File

@@ -21,21 +21,21 @@ Convert the logic to use <code>else if</code> statements.
```yml
tests:
- text: You should have at least two <code>else</code> statements
testString: 'assert(code.match(/else/g).length > 1, ''You should have at least two <code>else</code> statements'');'
testString: 'assert(code.match(/else/g).length > 1, "You should have at least two <code>else</code> statements");'
- text: You should have at least two <code>if</code> statements
testString: 'assert(code.match(/if/g).length > 1, ''You should have at least two <code>if</code> statements'');'
testString: 'assert(code.match(/if/g).length > 1, "You should have at least two <code>if</code> statements");'
- text: You should have closing and opening curly braces for each condition
testString: 'assert(code.match(/if\s*\((.+)\)\s*\{[\s\S]+\}\s*else if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s*\{[\s\S]+\s*\}/), ''You should have closing and opening curly braces for each condition in your if else statement'');'
testString: 'assert(code.match(/if\s*\((.+)\)\s*\{[\s\S]+\}\s*else if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s*\{[\s\S]+\s*\}/), "You should have closing and opening curly braces for each condition in your if else statement");'
- text: <code>testElseIf(0)</code> should return "Smaller than 5"
testString: 'assert(testElseIf(0) === "Smaller than 5", ''<code>testElseIf(0)</code> should return "Smaller than 5"'');'
testString: 'assert(testElseIf(0) === "Smaller than 5", "<code>testElseIf(0)</code> should return "Smaller than 5"");'
- text: <code>testElseIf(5)</code> should return "Between 5 and 10"
testString: 'assert(testElseIf(5) === "Between 5 and 10", ''<code>testElseIf(5)</code> should return "Between 5 and 10"'');'
testString: 'assert(testElseIf(5) === "Between 5 and 10", "<code>testElseIf(5)</code> should return "Between 5 and 10"");'
- text: <code>testElseIf(7)</code> should return "Between 5 and 10"
testString: 'assert(testElseIf(7) === "Between 5 and 10", ''<code>testElseIf(7)</code> should return "Between 5 and 10"'');'
testString: 'assert(testElseIf(7) === "Between 5 and 10", "<code>testElseIf(7)</code> should return "Between 5 and 10"");'
- text: <code>testElseIf(10)</code> should return "Between 5 and 10"
testString: 'assert(testElseIf(10) === "Between 5 and 10", ''<code>testElseIf(10)</code> should return "Between 5 and 10"'');'
testString: 'assert(testElseIf(10) === "Between 5 and 10", "<code>testElseIf(10)</code> should return "Between 5 and 10"");'
- text: <code>testElseIf(12)</code> should return "Greater than 10"
testString: 'assert(testElseIf(12) === "Greater than 10", ''<code>testElseIf(12)</code> should return "Greater than 10"'');'
testString: 'assert(testElseIf(12) === "Greater than 10", "<code>testElseIf(12)</code> should return "Greater than 10"");'
```
@@ -51,11 +51,11 @@ function testElseIf(val) {
if (val > 10) {
return "Greater than 10";
}
if (val < 5) {
return "Smaller than 5";
}
return "Between 5 and 10";
}

View File

@@ -21,19 +21,19 @@ Combine the <code>if</code> statements into a single <code>if/else</code> statem
```yml
tests:
- text: You should only have one <code>if</code> statement in the editor
testString: 'assert(code.match(/if/g).length === 1, ''You should only have one <code>if</code> statement in the editor'');'
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement in the editor");'
- text: You should use an <code>else</code> statement
testString: 'assert(/else/g.test(code), ''You should use an <code>else</code> statement'');'
testString: 'assert(/else/g.test(code), "You should use an <code>else</code> statement");'
- text: <code>testElse(4)</code> should return "5 or Smaller"
testString: 'assert(testElse(4) === "5 or Smaller", ''<code>testElse(4)</code> should return "5 or Smaller"'');'
testString: 'assert(testElse(4) === "5 or Smaller", "<code>testElse(4)</code> should return "5 or Smaller"");'
- text: <code>testElse(5)</code> should return "5 or Smaller"
testString: 'assert(testElse(5) === "5 or Smaller", ''<code>testElse(5)</code> should return "5 or Smaller"'');'
testString: 'assert(testElse(5) === "5 or Smaller", "<code>testElse(5)</code> should return "5 or Smaller"");'
- text: <code>testElse(6)</code> should return "Bigger than 5"
testString: 'assert(testElse(6) === "Bigger than 5", ''<code>testElse(6)</code> should return "Bigger than 5"'');'
testString: 'assert(testElse(6) === "Bigger than 5", "<code>testElse(6)</code> should return "Bigger than 5"");'
- text: <code>testElse(10)</code> should return "Bigger than 5"
testString: 'assert(testElse(10) === "Bigger than 5", ''<code>testElse(10)</code> should return "Bigger than 5"'');'
testString: 'assert(testElse(10) === "Bigger than 5", "<code>testElse(10)</code> should return "Bigger than 5"");'
- text: Do not change the code above or below the lines.
testString: 'assert(/var result = "";/.test(code) && /return result;/.test(code), ''Do not change the code above or below the lines.'');'
testString: 'assert(/var result = "";/.test(code) && /return result;/.test(code), "Do not change the code above or below the lines.");'
```
@@ -48,15 +48,15 @@ tests:
function testElse(val) {
var result = "";
// Only change code below this line
if (val > 5) {
result = "Bigger than 5";
}
if (val <= 5) {
result = "5 or Smaller";
}
// Only change code above this line
return result;
}

View File

@@ -24,9 +24,9 @@ Push the odd numbers from 1 through 9 to <code>myArray</code> using a <code>for<
```yml
tests:
- text: You should be using a <code>for</code> loop for this.
testString: 'assert(code.match(/for\s*\(/g).length > 1, ''You should be using a <code>for</code> loop for this.'');'
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
- text: '<code>myArray</code> should equal <code>[1,3,5,7,9]</code>.'
testString: 'assert.deepEqual(myArray, [1,3,5,7,9], ''<code>myArray</code> should equal <code>[1,3,5,7,9]</code>.'');'
testString: 'assert.deepEqual(myArray, [1,3,5,7,9], "<code>myArray</code> should equal <code>[1,3,5,7,9]</code>.");'
```

View File

@@ -22,13 +22,13 @@ Declare and initialize a variable <code>total</code> to <code>0</code>. Use a <c
```yml
tests:
- text: <code>total</code> should be declared and initialized to 0
testString: 'assert(code.match(/var.*?total\s*=\s*0.*?;/), ''<code>total</code> should be declared and initialized to 0'');'
testString: 'assert(code.match(/var.*?total\s*=\s*0.*?;/), "<code>total</code> should be declared and initialized to 0");'
- text: <code>total</code> should equal 20
testString: 'assert(total === 20, ''<code>total</code> should equal 20'');'
testString: 'assert(total === 20, "<code>total</code> should equal 20");'
- text: You should use a <code>for</code> loop to iterate through <code>myArr</code>
testString: 'assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/), ''You should use a <code>for</code> loop to iterate through <code>myArr</code>'');'
testString: 'assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/), "You should use a <code>for</code> loop to iterate through <code>myArr</code>");'
- text: Do not set <code>total</code> to 20 directly
testString: 'assert(!code.match(/total[\s\+\-]*=\s*(\d(?!\s*[;,])|[1-9])/g), ''Do not set <code>total</code> to 20 directly'');'
testString: 'assert(!code.match(/total[\s\+\-]*=\s*(\d(?!\s*[;,])|[1-9])/g), "Do not set <code>total</code> to 20 directly");'
```

View File

@@ -31,11 +31,11 @@ Change the <code>while</code> loop in the code to a <code>do...while</code> loop
```yml
tests:
- text: You should be using a <code>do...while</code> loop for this.
testString: 'assert(code.match(/do/g), ''You should be using a <code>do...while</code> loop for this.'');'
testString: 'assert(code.match(/do/g), "You should be using a <code>do...while</code> loop for this.");'
- text: '<code>myArray</code> should equal <code>[10]</code>.'
testString: 'assert.deepEqual(myArray, [10], ''<code>myArray</code> should equal <code>[10]</code>.'');'
testString: 'assert.deepEqual(myArray, [10], "<code>myArray</code> should equal <code>[10]</code>.");'
- text: <code>i</code> should equal <code>11</code>
testString: 'assert.deepEqual(i, 11, ''<code>i</code> should equal <code>11</code>'');'
testString: 'assert.deepEqual(i, 11, "<code>i</code> should equal <code>11</code>");'
```

View File

@@ -29,9 +29,9 @@ Use a <code>for</code> loop to work to push the values 1 through 5 onto <code>my
```yml
tests:
- text: You should be using a <code>for</code> loop for this.
testString: 'assert(code.match(/for\s*\(/g).length > 1, ''You should be using a <code>for</code> loop for this.'');'
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
- text: '<code>myArray</code> should equal <code>[1,2,3,4,5]</code>.'
testString: 'assert.deepEqual(myArray, [1,2,3,4,5], ''<code>myArray</code> should equal <code>[1,2,3,4,5]</code>.'');'
testString: 'assert.deepEqual(myArray, [1,2,3,4,5], "<code>myArray</code> should equal <code>[1,2,3,4,5]</code>.");'
```

View File

@@ -23,9 +23,9 @@ Push the numbers 0 through 4 to <code>myArray</code> using a <code>while</code>
```yml
tests:
- text: You should be using a <code>while</code> loop for this.
testString: 'assert(code.match(/while/g), ''You should be using a <code>while</code> loop for this.'');'
testString: 'assert(code.match(/while/g), "You should be using a <code>while</code> loop for this.");'
- text: '<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.'
testString: 'assert.deepEqual(myArray, [0,1,2,3,4], ''<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.'');'
testString: 'assert.deepEqual(myArray, [0,1,2,3,4], "<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.");'
```

View File

@@ -24,9 +24,9 @@ Declare a local variable <code>myVar</code> inside <code>myLocalScope</code>. Ru
```yml
tests:
- text: No global <code>myVar</code> variable
testString: 'assert(typeof myVar === ''undefined'', ''No global <code>myVar</code> variable'');'
testString: 'assert(typeof myVar === "undefined", "No global <code>myVar</code> variable");'
- text: Add a local <code>myVar</code> variable
testString: 'assert(/var\s+myVar/.test(code), ''Add a local <code>myVar</code> variable'');'
testString: 'assert(/var\s+myVar/.test(code), "Add a local <code>myVar</code> variable");'
```
@@ -40,7 +40,7 @@ tests:
```js
function myLocalScope() {
'use strict'; // you shouldn't need to edit this line
console.log(myVar);
}
myLocalScope();
@@ -100,7 +100,7 @@ console.info('after the test');
```js
function myLocalScope() {
'use strict';
var myVar;
console.log(myVar);
}

View File

@@ -28,11 +28,11 @@ Change the order of logic in the function so that it will return the correct sta
```yml
tests:
- text: <code>orderMyLogic(4)</code> should return "Less than 5"
testString: 'assert(orderMyLogic(4) === "Less than 5", ''<code>orderMyLogic(4)</code> should return "Less than 5"'');'
testString: 'assert(orderMyLogic(4) === "Less than 5", "<code>orderMyLogic(4)</code> should return "Less than 5"");'
- text: <code>orderMyLogic(6)</code> should return "Less than 10"
testString: 'assert(orderMyLogic(6) === "Less than 10", ''<code>orderMyLogic(6)</code> should return "Less than 10"'');'
testString: 'assert(orderMyLogic(6) === "Less than 10", "<code>orderMyLogic(6)</code> should return "Less than 10"");'
- text: <code>orderMyLogic(11)</code> should return "Greater than or equal to 10"
testString: 'assert(orderMyLogic(11) === "Greater than or equal to 10", ''<code>orderMyLogic(11)</code> should return "Greater than or equal to 10"'');'
testString: 'assert(orderMyLogic(11) === "Greater than or equal to 10", "<code>orderMyLogic(11)</code> should return "Greater than or equal to 10"");'
```
@@ -71,7 +71,7 @@ orderMyLogic(7);
```js
function orderMyLogic(val) {
if(val < 5) {
return "Less than 5";
return "Less than 5";
} else if (val < 10) {
return "Less than 10";
} else {

View File

@@ -23,11 +23,11 @@ Use the <code>.pop()</code> function to remove the last item from <code>myArray<
```yml
tests:
- text: '<code>myArray</code> should only contain <code>[["John", 23]]</code>.'
testString: 'assert((function(d){if(d[0][0] == ''John'' && d[0][1] === 23 && d[1] == undefined){return true;}else{return false;}})(myArray), ''<code>myArray</code> should only contain <code>[["John", 23]]</code>.'');'
testString: 'assert((function(d){if(d[0][0] == "John" && d[0][1] === 23 && d[1] == undefined){return true;}else{return false;}})(myArray), "<code>myArray</code> should only contain <code>[["John", 23]]</code>.");'
- text: Use <code>pop()</code> on <code>myArray</code>
testString: 'assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(code), ''Use <code>pop()</code> on <code>myArray</code>'');'
testString: 'assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(code), "Use <code>pop()</code> on <code>myArray</code>");'
- text: '<code>removedFromMyArray</code> should only contain <code>["cat", 2]</code>.'
testString: 'assert((function(d){if(d[0] == ''cat'' && d[1] === 2 && d[2] == undefined){return true;}else{return false;}})(removedFromMyArray), ''<code>removedFromMyArray</code> should only contain <code>["cat", 2]</code>.'');'
testString: 'assert((function(d){if(d[0] == "cat" && d[1] === 2 && d[2] == undefined){return true;}else{return false;}})(removedFromMyArray), "<code>removedFromMyArray</code> should only contain <code>["cat", 2]</code>.");'
```
@@ -41,7 +41,7 @@ tests:
```js
// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();
var removedFromOurArray = ourArray.pop();
// removedFromOurArray now equals 3, and ourArray now equals [1,2]
// Setup

View File

@@ -22,7 +22,7 @@ Push <code>["dog", 3]</code> onto the end of the <code>myArray</code> variable.
```yml
tests:
- text: '<code>myArray</code> should now equal <code>[["John", 23], ["cat", 2], ["dog", 3]]</code>.'
testString: 'assert((function(d){if(d[2] != undefined && d[0][0] == ''John'' && d[0][1] === 23 && d[2][0] == ''dog'' && d[2][1] === 3 && d[2].length == 2){return true;}else{return false;}})(myArray), ''<code>myArray</code> should now equal <code>[["John", 23], ["cat", 2], ["dog", 3]]</code>.'');'
testString: 'assert((function(d){if(d[2] != undefined && d[0][0] == "John" && d[0][1] === 23 && d[2][0] == "dog" && d[2][1] === 3 && d[2].length == 2){return true;}else{return false;}})(myArray), "<code>myArray</code> should now equal <code>[["John", 23], ["cat", 2], ["dog", 3]]</code>.");'
```
@@ -36,7 +36,7 @@ tests:
```js
// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.push(["happy", "joy"]);
ourArray.push(["happy", "joy"]);
// ourArray now equals ["Stimpson", "J", "cat", ["happy", "joy"]]
// Setup

View File

@@ -21,9 +21,9 @@ Use the <code>.shift()</code> function to remove the first item from <code>myArr
```yml
tests:
- text: '<code>myArray</code> should now equal <code>[["dog", 3]]</code>.'
testString: 'assert((function(d){if(d[0][0] == ''dog'' && d[0][1] === 3 && d[1] == undefined){return true;}else{return false;}})(myArray), ''<code>myArray</code> should now equal <code>[["dog", 3]]</code>.'');'
testString: 'assert((function(d){if(d[0][0] == "dog" && d[0][1] === 3 && d[1] == undefined){return true;}else{return false;}})(myArray), "<code>myArray</code> should now equal <code>[["dog", 3]]</code>.");'
- text: '<code>removedFromMyArray</code> should contain <code>["John", 23]</code>.'
testString: 'assert((function(d){if(d[0] == ''John'' && d[1] === 23 && typeof removedFromMyArray === ''object''){return true;}else{return false;}})(removedFromMyArray), ''<code>removedFromMyArray</code> should contain <code>["John", 23]</code>.'');'
testString: 'assert((function(d){if(d[0] == "John" && d[1] === 23 && typeof removedFromMyArray === "object"){return true;}else{return false;}})(removedFromMyArray), "<code>removedFromMyArray</code> should contain <code>["John", 23]</code>.");'
```

View File

@@ -21,7 +21,7 @@ Add <code>["Paul",35]</code> to the beginning of the <code>myArray</code> variab
```yml
tests:
- text: '<code>myArray</code> should now have [["Paul", 35], ["dog", 3]].'
testString: 'assert((function(d){if(typeof d[0] === "object" && d[0][0] == ''Paul'' && d[0][1] === 35 && d[1][0] != undefined && d[1][0] == ''dog'' && d[1][1] != undefined && d[1][1] == 3){return true;}else{return false;}})(myArray), ''<code>myArray</code> should now have [["Paul", 35], ["dog", 3]].'');'
testString: 'assert((function(d){if(typeof d[0] === "object" && d[0][0] == "Paul" && d[0][1] === 35 && d[1][0] != undefined && d[1][0] == "dog" && d[1][1] != undefined && d[1][1] == 3){return true;}else{return false;}})(myArray), "<code>myArray</code> should now have [["Paul", 35], ["dog", 3]].");'
```
@@ -36,7 +36,7 @@ tests:
// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy");
ourArray.unshift("Happy");
// ourArray now equals ["Happy", "J", "cat"]
// Setup

View File

@@ -27,23 +27,23 @@ Add a new album to the <code>myMusic</code> array. Add <code>artist</code> and <
```yml
tests:
- text: <code>myMusic</code> should be an array
testString: 'assert(Array.isArray(myMusic), ''<code>myMusic</code> should be an array'');'
testString: 'assert(Array.isArray(myMusic), "<code>myMusic</code> should be an array");'
- text: <code>myMusic</code> should have at least two elements
testString: 'assert(myMusic.length > 1, ''<code>myMusic</code> should have at least two elements'');'
testString: 'assert(myMusic.length > 1, "<code>myMusic</code> should have at least two elements");'
- text: '<code>myMusic[1]</code> should be an object'
testString: 'assert(typeof myMusic[1] === ''object'', ''<code>myMusic[1]</code> should be an object'');'
testString: 'assert(typeof myMusic[1] === "object", "<code>myMusic[1]</code> should be an object");'
- text: '<code>myMusic[1]</code> should have at least 4 properties'
testString: 'assert(Object.keys(myMusic[1]).length > 3, ''<code>myMusic[1]</code> should have at least 4 properties'');'
testString: 'assert(Object.keys(myMusic[1]).length > 3, "<code>myMusic[1]</code> should have at least 4 properties");'
- text: '<code>myMusic[1]</code> should contain an <code>artist</code> property which is a string'
testString: 'assert(myMusic[1].hasOwnProperty(''artist'') && typeof myMusic[1].artist === ''string'', ''<code>myMusic[1]</code> should contain an <code>artist</code> property which is a string'');'
testString: 'assert(myMusic[1].hasOwnProperty("artist") && typeof myMusic[1].artist === "string", "<code>myMusic[1]</code> should contain an <code>artist</code> property which is a string");'
- text: '<code>myMusic[1]</code> should contain a <code>title</code> property which is a string'
testString: 'assert(myMusic[1].hasOwnProperty(''title'') && typeof myMusic[1].title === ''string'', ''<code>myMusic[1]</code> should contain a <code>title</code> property which is a string'');'
testString: 'assert(myMusic[1].hasOwnProperty("title") && typeof myMusic[1].title === "string", "<code>myMusic[1]</code> should contain a <code>title</code> property which is a string");'
- text: '<code>myMusic[1]</code> should contain a <code>release_year</code> property which is a number'
testString: 'assert(myMusic[1].hasOwnProperty(''release_year'') && typeof myMusic[1].release_year === ''number'', ''<code>myMusic[1]</code> should contain a <code>release_year</code> property which is a number'');'
testString: 'assert(myMusic[1].hasOwnProperty("release_year") && typeof myMusic[1].release_year === "number", "<code>myMusic[1]</code> should contain a <code>release_year</code> property which is a number");'
- text: '<code>myMusic[1]</code> should contain a <code>formats</code> property which is an array'
testString: 'assert(myMusic[1].hasOwnProperty(''formats'') && Array.isArray(myMusic[1].formats), ''<code>myMusic[1]</code> should contain a <code>formats</code> property which is an array'');'
testString: 'assert(myMusic[1].hasOwnProperty("formats") && Array.isArray(myMusic[1].formats), "<code>myMusic[1]</code> should contain a <code>formats</code> property which is an array");'
- text: <code>formats</code> should be an array of strings with at least two elements
testString: 'assert(myMusic[1].formats.every(function(item) { return (typeof item === "string")}) && myMusic[1].formats.length > 1, ''<code>formats</code> should be an array of strings with at least two elements'');'
testString: 'assert(myMusic[1].formats.every(function(item) { return (typeof item === "string")}) && myMusic[1].formats.length > 1, "<code>formats</code> should be an array of strings with at least two elements");'
```
@@ -60,7 +60,7 @@ var myMusic = [
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"formats": [
"CD",
"8T",
"LP"
@@ -96,19 +96,19 @@ var myMusic = [
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
},
{
"artist": "ABBA",
"title": "Ring Ring",
"release_year": 1973,
"formats": [
"CS",
"8T",
"formats": [
"CS",
"8T",
"LP",
"CD",
]

View File

@@ -23,9 +23,9 @@ Modify the data stored at index <code>0</code> of <code>myArray</code> to a valu
```yml
tests:
- text: '<code>myArray</code> should now be [45,64,99].'
testString: 'assert((function(){if(typeof myArray != ''undefined'' && myArray[0] == 45 && myArray[1] == 64 && myArray[2] == 99){return true;}else{return false;}})(), ''<code>myArray</code> should now be [45,64,99].'');'
testString: 'assert((function(){if(typeof myArray != "undefined" && myArray[0] == 45 && myArray[1] == 64 && myArray[2] == 99){return true;}else{return false;}})(), "<code>myArray</code> should now be [45,64,99].");'
- text: You should be using correct index to modify the value in <code>myArray</code>.
testString: 'assert((function(){if(code.match(/myArray\[0\]\s*=\s*/g)){return true;}else{return false;}})(), ''You should be using correct index to modify the value in <code>myArray</code>.'');'
testString: 'assert((function(){if(code.match(/myArray\[0\]\s*=\s*/g)){return true;}else{return false;}})(), "You should be using correct index to modify the value in <code>myArray</code>.");'
```

View File

@@ -23,27 +23,27 @@ Write a switch statement to set <code>answer</code> for the following ranges:<br
```yml
tests:
- text: <code>sequentialSizes(1)</code> should return "Low"
testString: 'assert(sequentialSizes(1) === "Low", ''<code>sequentialSizes(1)</code> should return "Low"'');'
testString: 'assert(sequentialSizes(1) === "Low", "<code>sequentialSizes(1)</code> should return "Low"");'
- text: <code>sequentialSizes(2)</code> should return "Low"
testString: 'assert(sequentialSizes(2) === "Low", ''<code>sequentialSizes(2)</code> should return "Low"'');'
testString: 'assert(sequentialSizes(2) === "Low", "<code>sequentialSizes(2)</code> should return "Low"");'
- text: <code>sequentialSizes(3)</code> should return "Low"
testString: 'assert(sequentialSizes(3) === "Low", ''<code>sequentialSizes(3)</code> should return "Low"'');'
testString: 'assert(sequentialSizes(3) === "Low", "<code>sequentialSizes(3)</code> should return "Low"");'
- text: <code>sequentialSizes(4)</code> should return "Mid"
testString: 'assert(sequentialSizes(4) === "Mid", ''<code>sequentialSizes(4)</code> should return "Mid"'');'
testString: 'assert(sequentialSizes(4) === "Mid", "<code>sequentialSizes(4)</code> should return "Mid"");'
- text: <code>sequentialSizes(5)</code> should return "Mid"
testString: 'assert(sequentialSizes(5) === "Mid", ''<code>sequentialSizes(5)</code> should return "Mid"'');'
testString: 'assert(sequentialSizes(5) === "Mid", "<code>sequentialSizes(5)</code> should return "Mid"");'
- text: <code>sequentialSizes(6)</code> should return "Mid"
testString: 'assert(sequentialSizes(6) === "Mid", ''<code>sequentialSizes(6)</code> should return "Mid"'');'
testString: 'assert(sequentialSizes(6) === "Mid", "<code>sequentialSizes(6)</code> should return "Mid"");'
- text: <code>sequentialSizes(7)</code> should return "High"
testString: 'assert(sequentialSizes(7) === "High", ''<code>sequentialSizes(7)</code> should return "High"'');'
testString: 'assert(sequentialSizes(7) === "High", "<code>sequentialSizes(7)</code> should return "High"");'
- text: <code>sequentialSizes(8)</code> should return "High"
testString: 'assert(sequentialSizes(8) === "High", ''<code>sequentialSizes(8)</code> should return "High"'');'
testString: 'assert(sequentialSizes(8) === "High", "<code>sequentialSizes(8)</code> should return "High"");'
- text: <code>sequentialSizes(9)</code> should return "High"
testString: 'assert(sequentialSizes(9) === "High", ''<code>sequentialSizes(9)</code> should return "High"'');'
testString: 'assert(sequentialSizes(9) === "High", "<code>sequentialSizes(9)</code> should return "High"");'
- text: You should not use any <code>if</code> or <code>else</code> statements
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), ''You should not use any <code>if</code> or <code>else</code> statements'');'
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
- text: You should have nine <code>case</code> statements
testString: 'assert(code.match(/case/g).length === 9, ''You should have nine <code>case</code> statements'');'
testString: 'assert(code.match(/case/g).length === 9, "You should have nine <code>case</code> statements");'
```
@@ -58,11 +58,11 @@ tests:
function sequentialSizes(val) {
var answer = "";
// Only change code below this line
// Only change code above this line
return answer;
// Only change code above this line
return answer;
}
// Change this value to test
@@ -83,7 +83,7 @@ sequentialSizes(1);
```js
function sequentialSizes(val) {
var answer = "";
switch(val) {
case 1:
case 2:
@@ -100,8 +100,8 @@ function sequentialSizes(val) {
case 9:
answer = "High";
}
return answer;
return answer;
}
```

View File

@@ -21,9 +21,9 @@ Change the <code>0.0</code> so that product will equal <code>5.0</code>.
```yml
tests:
- text: The variable <code>product</code> should equal <code>5.0</code>.
testString: 'assert(product === 5.0, ''The variable <code>product</code> should equal <code>5.0</code>.'');'
testString: 'assert(product === 5.0, "The variable <code>product</code> should equal <code>5.0</code>.");'
- text: You should use the <code>*</code> operator
testString: 'assert(/\*/.test(code), ''You should use the <code>*</code> operator'');'
testString: 'assert(/\*/.test(code), "You should use the <code>*</code> operator");'
```

View File

@@ -25,9 +25,9 @@ Change the <code>0</code> so that product will equal <code>80</code>.
```yml
tests:
- text: Make the variable <code>product</code> equal 80
testString: 'assert(product === 80,''Make the variable <code>product</code> equal 80'');'
testString: 'assert(product === 80,"Make the variable <code>product</code> equal 80");'
- text: Use the <code>*</code> operator
testString: 'assert(/\*/.test(code), ''Use the <code>*</code> operator'');'
testString: 'assert(/\*/.test(code), "Use the <code>*</code> operator");'
```

View File

@@ -20,7 +20,7 @@ Create a nested array called <code>myArray</code>.
```yml
tests:
- text: <code>myArray</code> should have at least one array nested within another array.
testString: 'assert(Array.isArray(myArray) && myArray.some(Array.isArray), ''<code>myArray</code> should have at least one array nested within another array.'');'
testString: 'assert(Array.isArray(myArray) && myArray.some(Array.isArray), "<code>myArray</code> should have at least one array nested within another array.");'
```

View File

@@ -22,11 +22,11 @@ Modify function <code>multiplyAll</code> so that it multiplies the <code>product
```yml
tests:
- text: '<code>multiplyAll([[1],[2],[3]])</code> should return <code>6</code>'
testString: 'assert(multiplyAll([[1],[2],[3]]) === 6, ''<code>multiplyAll([[1],[2],[3]])</code> should return <code>6</code>'');'
testString: 'assert(multiplyAll([[1],[2],[3]]) === 6, "<code>multiplyAll([[1],[2],[3]])</code> should return <code>6</code>");'
- text: '<code>multiplyAll([[1,2],[3,4],[5,6,7]])</code> should return <code>5040</code>'
testString: 'assert(multiplyAll([[1,2],[3,4],[5,6,7]]) === 5040, ''<code>multiplyAll([[1,2],[3,4],[5,6,7]])</code> should return <code>5040</code>'');'
testString: 'assert(multiplyAll([[1,2],[3,4],[5,6,7]]) === 5040, "<code>multiplyAll([[1,2],[3,4],[5,6,7]])</code> should return <code>5040</code>");'
- text: '<code>multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]])</code> should return <code>54</code>'
testString: 'assert(multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) === 54, ''<code>multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]])</code> should return <code>54</code>'');'
testString: 'assert(multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) === 54, "<code>multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]])</code> should return <code>54</code>");'
```
@@ -41,7 +41,7 @@ tests:
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
// Only change code above this line
return product;
}

View File

@@ -25,13 +25,13 @@ We have passed two arguments, <code>"Hello"</code> and <code>"World"</code>. Ins
```yml
tests:
- text: <code>functionWithArgs</code> should be a function
testString: 'assert(typeof functionWithArgs === ''function'', ''<code>functionWithArgs</code> should be a function'');'
testString: 'assert(typeof functionWithArgs === "function", "<code>functionWithArgs</code> should be a function");'
- text: '<code>functionWithArgs(1,2)</code> should output <code>3</code>'
testString: 'if(typeof functionWithArgs === "function") { capture(); functionWithArgs(1,2); uncapture(); } assert(logOutput == 3, ''<code>functionWithArgs(1,2)</code> should output <code>3</code>'');'
testString: 'if(typeof functionWithArgs === "function") { capture(); functionWithArgs(1,2); uncapture(); } assert(logOutput == 3, "<code>functionWithArgs(1,2)</code> should output <code>3</code>");'
- text: '<code>functionWithArgs(7,9)</code> should output <code>16</code>'
testString: 'if(typeof functionWithArgs === "function") { capture(); functionWithArgs(7,9); uncapture(); } assert(logOutput == 16, ''<code>functionWithArgs(7,9)</code> should output <code>16</code>'');'
testString: 'if(typeof functionWithArgs === "function") { capture(); functionWithArgs(7,9); uncapture(); } assert(logOutput == 16, "<code>functionWithArgs(7,9)</code> should output <code>16</code>");'
- text: Call <code>functionWithArgs</code> with two numbers after you define it.
testString: 'assert(/^\s*functionWithArgs\s*\(\s*\d+\s*,\s*\d+\s*\)\s*;/m.test(code), ''Call <code>functionWithArgs</code> with two numbers after you define it.'');'
testString: 'assert(/^\s*functionWithArgs\s*\(\s*\d+\s*,\s*\d+\s*\)\s*;/m.test(code), "Call <code>functionWithArgs</code> with two numbers after you define it.");'
```

View File

@@ -25,11 +25,11 @@ The <code>compareEquality</code> function in the editor compares two values usin
```yml
tests:
- text: '<code>compareEquality(10, "10")</code> should return "Not Equal"'
testString: 'assert(compareEquality(10, "10") === "Not Equal", ''<code>compareEquality(10, "10")</code> should return "Not Equal"'');'
testString: 'assert(compareEquality(10, "10") === "Not Equal", "<code>compareEquality(10, "10")</code> should return "Not Equal"");'
- text: '<code>compareEquality("20", 20)</code> should return "Not Equal"'
testString: 'assert(compareEquality("20", 20) === "Not Equal", ''<code>compareEquality("20", 20)</code> should return "Not Equal"'');'
testString: 'assert(compareEquality("20", 20) === "Not Equal", "<code>compareEquality("20", 20)</code> should return "Not Equal"");'
- text: You should use the <code>===</code> operator
testString: 'assert(code.match(/===/g), ''You should use the <code>===</code> operator'');'
testString: 'assert(code.match(/===/g), "You should use the <code>===</code> operator");'
```

View File

@@ -25,17 +25,17 @@ If <code>prop</code> does not correspond to any valid properties of a contact fo
```yml
tests:
- text: '<code>"Kristian", "lastName"</code> should return <code>"Vos"</code>'
testString: 'assert(lookUpProfile(''Kristian'',''lastName'') === "Vos", ''<code>"Kristian", "lastName"</code> should return <code>"Vos"</code>'');'
testString: 'assert(lookUpProfile("Kristian","lastName") === "Vos", "<code>"Kristian", "lastName"</code> should return <code>"Vos"</code>");'
- text: '<code>"Sherlock", "likes"</code> should return <code>["Intriguing Cases", "Violin"]</code>'
testString: 'assert.deepEqual(lookUpProfile("Sherlock", "likes"), ["Intriguing Cases", "Violin"], ''<code>"Sherlock", "likes"</code> should return <code>["Intriguing Cases", "Violin"]</code>'');'
testString: 'assert.deepEqual(lookUpProfile("Sherlock", "likes"), ["Intriguing Cases", "Violin"], "<code>"Sherlock", "likes"</code> should return <code>["Intriguing Cases", "Violin"]</code>");'
- text: '<code>"Harry","likes"</code> should return an array'
testString: 'assert(typeof lookUpProfile("Harry", "likes") === "object", ''<code>"Harry","likes"</code> should return an array'');'
testString: 'assert(typeof lookUpProfile("Harry", "likes") === "object", "<code>"Harry","likes"</code> should return an array");'
- text: '<code>"Bob", "number"</code> should return "No such contact"'
testString: 'assert(lookUpProfile("Bob", "number") === "No such contact", ''<code>"Bob", "number"</code> should return "No such contact"'');'
testString: 'assert(lookUpProfile("Bob", "number") === "No such contact", "<code>"Bob", "number"</code> should return "No such contact"");'
- text: '<code>"Bob", "potato"</code> should return "No such contact"'
testString: 'assert(lookUpProfile("Bob", "potato") === "No such contact", ''<code>"Bob", "potato"</code> should return "No such contact"'');'
testString: 'assert(lookUpProfile("Bob", "potato") === "No such contact", "<code>"Bob", "potato"</code> should return "No such contact"");'
- text: '<code>"Akira", "address"</code> should return "No such property"'
testString: 'assert(lookUpProfile("Akira", "address") === "No such property", ''<code>"Akira", "address"</code> should return "No such property"'');'
testString: 'assert(lookUpProfile("Akira", "address") === "No such property", "<code>"Akira", "address"</code> should return "No such property"");'
```

View File

@@ -28,9 +28,9 @@ Right now, the <code>&#60;a&#62;</code> tag in the string uses double quotes eve
```yml
tests:
- text: Remove all the <code>backslashes</code> (<code>\</code>)
testString: 'assert(!/\\/g.test(code) && myStr.match(''\\s*<a href\\s*=\\s*"http://www.example.com"\\s*target\\s*=\\s*"_blank">\\s*Link\\s*</a>\\s*''), ''Remove all the <code>backslashes</code> (<code>\</code>)'');'
testString: 'assert(!/\\/g.test(code) && myStr.match("\\s*<a href\\s*=\\s*"http://www.example.com"\\s*target\\s*=\\s*"_blank">\\s*Link\\s*</a>\\s*"), "Remove all the <code>backslashes</code> (<code>\</code>)");'
- text: 'You should have two single quotes <code>&#39;</code> and four double quotes <code>&quot;</code>'
testString: 'assert(code.match(/"/g).length === 4 && code.match(/''/g).length === 2, ''You should have two single quotes <code>&#39;</code> and four double quotes <code>&quot;</code>'');'
testString: 'assert(code.match(/"/g).length === 4 && code.match(/"/g).length === 2, "You should have two single quotes <code>&#39;</code> and four double quotes <code>&quot;</code>");'
```

View File

@@ -30,19 +30,19 @@ You may refer back to <a href="javascript-algorithms-and-data-structures/basic-j
```yml
tests:
- text: 'After <code>updateRecords(5439, "artist", "ABBA")</code>, <code>artist</code> should be <code>"ABBA"</code>'
testString: 'collection = collectionCopy; assert(updateRecords(5439, "artist", "ABBA")[5439]["artist"] === "ABBA", ''After <code>updateRecords(5439, "artist", "ABBA")</code>, <code>artist</code> should be <code>"ABBA"</code>'');'
testString: 'collection = collectionCopy; assert(updateRecords(5439, "artist", "ABBA")[5439]["artist"] === "ABBA", "After <code>updateRecords(5439, "artist", "ABBA")</code>, <code>artist</code> should be <code>"ABBA"</code>");'
- text: 'After <code>updateRecords(5439, "tracks", "Take a Chance on Me")</code>, <code>tracks</code> should have <code>"Take a Chance on Me"</code> as the last element.'
testString: 'assert(updateRecords(5439, "tracks", "Take a Chance on Me")[5439]["tracks"].pop() === "Take a Chance on Me", ''After <code>updateRecords(5439, "tracks", "Take a Chance on Me")</code>, <code>tracks</code> should have <code>"Take a Chance on Me"</code> as the last element.'');'
testString: 'assert(updateRecords(5439, "tracks", "Take a Chance on Me")[5439]["tracks"].pop() === "Take a Chance on Me", "After <code>updateRecords(5439, "tracks", "Take a Chance on Me")</code>, <code>tracks</code> should have <code>"Take a Chance on Me"</code> as the last element.");'
- text: 'After <code>updateRecords(2548, "artist", "")</code>, <code>artist</code> should not be set'
testString: 'updateRecords(2548, "artist", ""); assert(!collection[2548].hasOwnProperty("artist"), ''After <code>updateRecords(2548, "artist", "")</code>, <code>artist</code> should not be set'');'
testString: 'updateRecords(2548, "artist", ""); assert(!collection[2548].hasOwnProperty("artist"), "After <code>updateRecords(2548, "artist", "")</code>, <code>artist</code> should not be set");'
- text: 'After <code>updateRecords(1245, "tracks", "Addicted to Love")</code>, <code>tracks</code> should have <code>"Addicted to Love"</code> as the last element.'
testString: 'assert(updateRecords(1245, "tracks", "Addicted to Love")[1245]["tracks"].pop() === "Addicted to Love", ''After <code>updateRecords(1245, "tracks", "Addicted to Love")</code>, <code>tracks</code> should have <code>"Addicted to Love"</code> as the last element.'');'
testString: 'assert(updateRecords(1245, "tracks", "Addicted to Love")[1245]["tracks"].pop() === "Addicted to Love", "After <code>updateRecords(1245, "tracks", "Addicted to Love")</code>, <code>tracks</code> should have <code>"Addicted to Love"</code> as the last element.");'
- text: 'After <code>updateRecords(2468, "tracks", "Free")</code>, <code>tracks</code> should have <code>"1999"</code> as the first element.'
testString: 'assert(updateRecords(2468, "tracks", "Free")[2468]["tracks"][0] === "1999", ''After <code>updateRecords(2468, "tracks", "Free")</code>, <code>tracks</code> should have <code>"1999"</code> as the first element.'');'
testString: 'assert(updateRecords(2468, "tracks", "Free")[2468]["tracks"][0] === "1999", "After <code>updateRecords(2468, "tracks", "Free")</code>, <code>tracks</code> should have <code>"1999"</code> as the first element.");'
- text: 'After <code>updateRecords(2548, "tracks", "")</code>, <code>tracks</code> should not be set'
testString: 'updateRecords(2548, "tracks", ""); assert(!collection[2548].hasOwnProperty("tracks"), ''After <code>updateRecords(2548, "tracks", "")</code>, <code>tracks</code> should not be set'');'
testString: 'updateRecords(2548, "tracks", ""); assert(!collection[2548].hasOwnProperty("tracks"), "After <code>updateRecords(2548, "tracks", "")</code>, <code>tracks</code> should not be set");'
- text: 'After <code>updateRecords(1245, "album", "Riptide")</code>, <code>album</code> should be <code>"Riptide"</code>'
testString: 'assert(updateRecords(1245, "album", "Riptide")[1245]["album"] === "Riptide", ''After <code>updateRecords(1245, "album", "Riptide")</code>, <code>album</code> should be <code>"Riptide"</code>'');'
testString: 'assert(updateRecords(1245, "album", "Riptide")[1245]["album"] === "Riptide", "After <code>updateRecords(1245, "album", "Riptide")</code>, <code>album</code> should be <code>"Riptide"</code>");'
```
@@ -59,17 +59,17 @@ var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
@@ -85,8 +85,8 @@ var collectionCopy = JSON.parse(JSON.stringify(collection));
// Only change code below this line
function updateRecords(id, prop, value) {
return collection;
}
@@ -118,17 +118,17 @@ var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
@@ -151,7 +151,7 @@ function updateRecords(id, prop, value) {
} else {
collection[id][prop] = value;
}
return collection;
}
```

View File

@@ -23,25 +23,25 @@ Change the chained <code>if</code>/<code>else if</code> statements into a <code>
```yml
tests:
- text: You should not use any <code>else</code> statements anywhere in the editor
testString: 'assert(!/else/g.test(code), ''You should not use any <code>else</code> statements anywhere in the editor'');'
testString: 'assert(!/else/g.test(code), "You should not use any <code>else</code> statements anywhere in the editor");'
- text: You should not use any <code>if</code> statements anywhere in the editor
testString: 'assert(!/if/g.test(code), ''You should not use any <code>if</code> statements anywhere in the editor'');'
testString: 'assert(!/if/g.test(code), "You should not use any <code>if</code> statements anywhere in the editor");'
- text: You should have at least four <code>break</code> statements
testString: 'assert(code.match(/break/g).length >= 4, ''You should have at least four <code>break</code> statements'');'
testString: 'assert(code.match(/break/g).length >= 4, "You should have at least four <code>break</code> statements");'
- text: <code>chainToSwitch("bob")</code> should be "Marley"
testString: 'assert(chainToSwitch("bob") === "Marley", ''<code>chainToSwitch("bob")</code> should be "Marley"'');'
testString: 'assert(chainToSwitch("bob") === "Marley", "<code>chainToSwitch("bob")</code> should be "Marley"");'
- text: <code>chainToSwitch(42)</code> should be "The Answer"
testString: 'assert(chainToSwitch(42) === "The Answer", ''<code>chainToSwitch(42)</code> should be "The Answer"'');'
testString: 'assert(chainToSwitch(42) === "The Answer", "<code>chainToSwitch(42)</code> should be "The Answer"");'
- text: '<code>chainToSwitch(1)</code> should be "There is no #1"'
testString: 'assert(chainToSwitch(1) === "There is no #1", ''<code>chainToSwitch(1)</code> should be "There is no #1"'');'
testString: 'assert(chainToSwitch(1) === "There is no #1", "<code>chainToSwitch(1)</code> should be "There is no #1"");'
- text: <code>chainToSwitch(99)</code> should be "Missed me by this much!"
testString: 'assert(chainToSwitch(99) === "Missed me by this much!", ''<code>chainToSwitch(99)</code> should be "Missed me by this much!"'');'
testString: 'assert(chainToSwitch(99) === "Missed me by this much!", "<code>chainToSwitch(99)</code> should be "Missed me by this much!"");'
- text: <code>chainToSwitch(7)</code> should be "Ate Nine"
testString: 'assert(chainToSwitch(7) === "Ate Nine", ''<code>chainToSwitch(7)</code> should be "Ate Nine"'');'
testString: 'assert(chainToSwitch(7) === "Ate Nine", "<code>chainToSwitch(7)</code> should be "Ate Nine"");'
- text: <code>chainToSwitch("John")</code> should be "" (empty string)
testString: 'assert(chainToSwitch("John") === "", ''<code>chainToSwitch("John")</code> should be "" (empty string)'');'
testString: 'assert(chainToSwitch("John") === "", "<code>chainToSwitch("John")</code> should be "" (empty string)");'
- text: <code>chainToSwitch(156)</code> should be "" (empty string)
testString: 'assert(chainToSwitch(156) === "", ''<code>chainToSwitch(156)</code> should be "" (empty string)'');'
testString: 'assert(chainToSwitch(156) === "", "<code>chainToSwitch(156)</code> should be "" (empty string)");'
```
@@ -56,7 +56,7 @@ tests:
function chainToSwitch(val) {
var answer = "";
// Only change code below this line
if (val === "bob") {
answer = "Marley";
} else if (val === 42) {
@@ -68,9 +68,9 @@ function chainToSwitch(val) {
} else if (val === 7) {
answer = "Ate Nine";
}
// Only change code above this line
return answer;
// Only change code above this line
return answer;
}
// Change this value to test
@@ -108,7 +108,7 @@ function chainToSwitch(val) {
case 7:
answer = "Ate Nine";
}
return answer;
return answer;
}
```

View File

@@ -23,13 +23,13 @@ Create a function <code>timesFive</code> that accepts one argument, multiplies i
```yml
tests:
- text: <code>timesFive</code> should be a function
testString: 'assert(typeof timesFive === ''function'', ''<code>timesFive</code> should be a function'');'
testString: 'assert(typeof timesFive === "function", "<code>timesFive</code> should be a function");'
- text: <code>timesFive(5)</code> should return <code>25</code>
testString: 'assert(timesFive(5) === 25, ''<code>timesFive(5)</code> should return <code>25</code>'');'
testString: 'assert(timesFive(5) === 25, "<code>timesFive(5)</code> should return <code>25</code>");'
- text: <code>timesFive(2)</code> should return <code>10</code>
testString: 'assert(timesFive(2) === 10, ''<code>timesFive(2)</code> should return <code>10</code>'');'
testString: 'assert(timesFive(2) === 10, "<code>timesFive(2)</code> should return <code>10</code>");'
- text: <code>timesFive(0)</code> should return <code>0</code>
testString: 'assert(timesFive(0) === 0, ''<code>timesFive(0)</code> should return <code>0</code>'');'
testString: 'assert(timesFive(0) === 0, "<code>timesFive(0)</code> should return <code>0</code>");'
```

View File

@@ -24,17 +24,17 @@ Modify the function <code>abTest</code> so that if <code>a</code> or <code>b</co
```yml
tests:
- text: '<code>abTest(2,2)</code> should return a number'
testString: 'assert(typeof abTest(2,2) === ''number'' , ''<code>abTest(2,2)</code> should return a number'');'
testString: 'assert(typeof abTest(2,2) === "number" , "<code>abTest(2,2)</code> should return a number");'
- text: '<code>abTest(2,2)</code> should return <code>8</code>'
testString: 'assert(abTest(2,2) === 8 , ''<code>abTest(2,2)</code> should return <code>8</code>'');'
testString: 'assert(abTest(2,2) === 8 , "<code>abTest(2,2)</code> should return <code>8</code>");'
- text: '<code>abTest(-2,2)</code> should return <code>undefined</code>'
testString: 'assert(abTest(-2,2) === undefined , ''<code>abTest(-2,2)</code> should return <code>undefined</code>'');'
testString: 'assert(abTest(-2,2) === undefined , "<code>abTest(-2,2)</code> should return <code>undefined</code>");'
- text: '<code>abTest(2,-2)</code> should return <code>undefined</code>'
testString: 'assert(abTest(2,-2) === undefined , ''<code>abTest(2,-2)</code> should return <code>undefined</code>'');'
testString: 'assert(abTest(2,-2) === undefined , "<code>abTest(2,-2)</code> should return <code>undefined</code>");'
- text: '<code>abTest(2,8)</code> should return <code>18</code>'
testString: 'assert(abTest(2,8) === 18 , ''<code>abTest(2,8)</code> should return <code>18</code>'');'
testString: 'assert(abTest(2,8) === 18 , "<code>abTest(2,8)</code> should return <code>18</code>");'
- text: '<code>abTest(3,3)</code> should return <code>12</code>'
testString: 'assert(abTest(3,3) === 12 , ''<code>abTest(3,3)</code> should return <code>12</code>'');'
testString: 'assert(abTest(3,3) === 12 , "<code>abTest(3,3)</code> should return <code>12</code>");'
```
@@ -49,9 +49,9 @@ tests:
// Setup
function abTest(a, b) {
// Only change code below this line
// Only change code above this line
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
@@ -75,7 +75,7 @@ abTest(2,2);
function abTest(a, b) {
if(a < 0 || b < 0) {
return undefined;
}
}
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
```

View File

@@ -24,11 +24,11 @@ Fix the function <code>isLess</code> to remove the <code>if/else</code> statemen
```yml
tests:
- text: '<code>isLess(10,15)</code> should return <code>true</code>'
testString: 'assert(isLess(10,15) === true, ''<code>isLess(10,15)</code> should return <code>true</code>'');'
testString: 'assert(isLess(10,15) === true, "<code>isLess(10,15)</code> should return <code>true</code>");'
- text: '<code>isLess(15,10)</code> should return <code>false</code>'
testString: 'assert(isLess(15, 10) === false, ''<code>isLess(15,10)</code> should return <code>false</code>'');'
testString: 'assert(isLess(15, 10) === false, "<code>isLess(15,10)</code> should return <code>false</code>");'
- text: You should not use any <code>if</code> or <code>else</code> statements
testString: 'assert(!/if|else/g.test(code), ''You should not use any <code>if</code> or <code>else</code> statements'');'
testString: 'assert(!/if|else/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
```

View File

@@ -23,17 +23,17 @@ Write a switch statement which tests <code>val</code> and sets <code>answer</cod
```yml
tests:
- text: <code>caseInSwitch(1)</code> should have a value of "alpha"
testString: 'assert(caseInSwitch(1) === "alpha", ''<code>caseInSwitch(1)</code> should have a value of "alpha"'');'
testString: 'assert(caseInSwitch(1) === "alpha", "<code>caseInSwitch(1)</code> should have a value of "alpha"");'
- text: <code>caseInSwitch(2)</code> should have a value of "beta"
testString: 'assert(caseInSwitch(2) === "beta", ''<code>caseInSwitch(2)</code> should have a value of "beta"'');'
testString: 'assert(caseInSwitch(2) === "beta", "<code>caseInSwitch(2)</code> should have a value of "beta"");'
- text: <code>caseInSwitch(3)</code> should have a value of "gamma"
testString: 'assert(caseInSwitch(3) === "gamma", ''<code>caseInSwitch(3)</code> should have a value of "gamma"'');'
testString: 'assert(caseInSwitch(3) === "gamma", "<code>caseInSwitch(3)</code> should have a value of "gamma"");'
- text: <code>caseInSwitch(4)</code> should have a value of "delta"
testString: 'assert(caseInSwitch(4) === "delta", ''<code>caseInSwitch(4)</code> should have a value of "delta"'');'
testString: 'assert(caseInSwitch(4) === "delta", "<code>caseInSwitch(4)</code> should have a value of "delta"");'
- text: You should not use any <code>if</code> or <code>else</code> statements
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), ''You should not use any <code>if</code> or <code>else</code> statements'');'
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
- text: You should have at least 3 <code>break</code> statements
testString: 'assert(code.match(/break/g).length > 2, ''You should have at least 3 <code>break</code> statements'');'
testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 <code>break</code> statements");'
```
@@ -48,11 +48,11 @@ tests:
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
// Only change code above this line
return answer;
// Only change code above this line
return answer;
}
// Change this value to test
@@ -87,7 +87,7 @@ function caseInSwitch(val) {
case 4:
answer = "delta";
}
return answer;
return answer;
}
```

View File

@@ -23,13 +23,13 @@ There should be at least 5 sub-arrays in the list.
```yml
tests:
- text: <code>myList</code> should be an array
testString: 'assert(isArray, ''<code>myList</code> should be an array'');'
testString: 'assert(isArray, "<code>myList</code> should be an array");'
- text: The first elements in each of your sub-arrays must all be strings
testString: 'assert(hasString, ''The first elements in each of your sub-arrays must all be strings'');'
testString: 'assert(hasString, "The first elements in each of your sub-arrays must all be strings");'
- text: The second elements in each of your sub-arrays must all be numbers
testString: 'assert(hasNumber, ''The second elements in each of your sub-arrays must all be numbers'');'
testString: 'assert(hasNumber, "The second elements in each of your sub-arrays must all be numbers");'
- text: You must have at least 5 items in your list
testString: 'assert(count > 4, ''You must have at least 5 items in your list'');'
testString: 'assert(count > 4, "You must have at least 5 items in your list");'
```

View File

@@ -23,15 +23,15 @@ The <code>nextInLine</code> function should then return the element that was rem
```yml
tests:
- text: '<code>nextInLine([], 5)</code> should return a number.'
testString: 'assert.isNumber(nextInLine([],5), ''<code>nextInLine([], 5)</code> should return a number.'');'
testString: 'assert.isNumber(nextInLine([],5), "<code>nextInLine([], 5)</code> should return a number.");'
- text: '<code>nextInLine([], 1)</code> should return <code>1</code>'
testString: 'assert(nextInLine([],1) === 1, ''<code>nextInLine([], 1)</code> should return <code>1</code>'');'
testString: 'assert(nextInLine([],1) === 1, "<code>nextInLine([], 1)</code> should return <code>1</code>");'
- text: '<code>nextInLine([2], 1)</code> should return <code>2</code>'
testString: 'assert(nextInLine([2],1) === 2, ''<code>nextInLine([2], 1)</code> should return <code>2</code>'');'
testString: 'assert(nextInLine([2],1) === 2, "<code>nextInLine([2], 1)</code> should return <code>2</code>");'
- text: '<code>nextInLine([5,6,7,8,9], 1)</code> should return <code>5</code>'
testString: 'assert(nextInLine([5,6,7,8,9],1) === 5, ''<code>nextInLine([5,6,7,8,9], 1)</code> should return <code>5</code>'');'
testString: 'assert(nextInLine([5,6,7,8,9],1) === 5, "<code>nextInLine([5,6,7,8,9], 1)</code> should return <code>5</code>");'
- text: 'After <code>nextInLine(testArr, 10)</code>, <code>testArr[4]</code> should be <code>10</code>'
testString: 'nextInLine(testArr, 10); assert(testArr[4] === 10, ''After <code>nextInLine(testArr, 10)</code>, <code>testArr[4]</code> should be <code>10</code>'');'
testString: 'nextInLine(testArr, 10); assert(testArr[4] === 10, "After <code>nextInLine(testArr, 10)</code>, <code>testArr[4]</code> should be <code>10</code>");'
```
@@ -45,7 +45,7 @@ tests:
```js
function nextInLine(arr, item) {
// Your code here
return item; // Change this line
}

View File

@@ -7,7 +7,7 @@ challengeType: 1
## Description
<section id='description'>
With JavaScript <code>array</code> variables, we can store several pieces of data in one place.
You start an array declaration with an opening square bracket, end it with a closing square bracket, and put a comma between each entry, like this:
You start an array declaration with an opening square bracket, end it with a closing square bracket, and put a comma between each entry, like this:
<code>var sandwich = ["peanut butter", "jelly", "bread"]</code>.
</section>
@@ -23,11 +23,11 @@ Modify the new array <code>myArray</code> so that it contains both a <code>strin
```yml
tests:
- text: <code>myArray</code> should be an <code>array</code>.
testString: 'assert(typeof myArray == ''object'', ''<code>myArray</code> should be an <code>array</code>.'');'
testString: 'assert(typeof myArray == "object", "<code>myArray</code> should be an <code>array</code>.");'
- text: The first item in <code>myArray</code> should be a <code>string</code>.
testString: 'assert(typeof myArray[0] !== ''undefined'' && typeof myArray[0] == ''string'', ''The first item in <code>myArray</code> should be a <code>string</code>.'');'
testString: 'assert(typeof myArray[0] !== "undefined" && typeof myArray[0] == "string", "The first item in <code>myArray</code> should be a <code>string</code>.");'
- text: The second item in <code>myArray</code> should be a <code>number</code>.
testString: 'assert(typeof myArray[1] !== ''undefined'' && typeof myArray[1] == ''number'', ''The second item in <code>myArray</code> should be a <code>number</code>.'');'
testString: 'assert(typeof myArray[1] !== "undefined" && typeof myArray[1] == "number", "The second item in <code>myArray</code> should be a <code>number</code>.");'
```

View File

@@ -26,13 +26,13 @@ Assign the contents of <code>a</code> to variable <code>b</code>.
```yml
tests:
- text: Do not change code above the line
testString: 'assert(/var a;/.test(code) && /var b = 2;/.test(code), ''Do not change code above the line'');'
testString: 'assert(/var a;/.test(code) && /var b = 2;/.test(code), "Do not change code above the line");'
- text: <code>a</code> should have a value of 7
testString: 'assert(typeof a === ''number'' && a === 7, ''<code>a</code> should have a value of 7'');'
testString: 'assert(typeof a === "number" && a === 7, "<code>a</code> should have a value of 7");'
- text: <code>b</code> should have a value of 7
testString: 'assert(typeof b === ''number'' && b === 7, ''<code>b</code> should have a value of 7'');'
testString: 'assert(typeof b === "number" && b === 7, "<code>b</code> should have a value of 7");'
- text: <code>a</code> should be assigned to <code>b</code> with <code>=</code>
testString: 'assert(/b\s*=\s*a\s*;/g.test(code), ''<code>a</code> should be assigned to <code>b</code> with <code>=</code>'');'
testString: 'assert(/b\s*=\s*a\s*;/g.test(code), "<code>a</code> should be assigned to <code>b</code> with <code>=</code>");'
```

View File

@@ -25,9 +25,9 @@ Change the <code>0</code> so the difference is <code>12</code>.
```yml
tests:
- text: Make the variable <code>difference</code> equal 12.
testString: 'assert(difference === 12, ''Make the variable <code>difference</code> equal 12.'');'
testString: 'assert(difference === 12, "Make the variable <code>difference</code> equal 12.");'
- text: Only subtract one number from 45.
testString: 'assert(/var\s*difference\s*=\s*45\s*-\s*[0-9]*;(?!\s*[a-zA-Z0-9]+)/.test(code),''Only subtract one number from 45.'');'
testString: 'assert(/var\s*difference\s*=\s*45\s*-\s*[0-9]*;(?!\s*[a-zA-Z0-9]+)/.test(code),"Only subtract one number from 45.");'
```

View File

@@ -22,11 +22,11 @@ Modify the function <code>checkObj</code> to test <code>myObj</code> for <code>c
```yml
tests:
- text: <code>checkObj("gift")</code> should return <code>"pony"</code>.
testString: 'assert(checkObj("gift") === "pony", ''<code>checkObj("gift")</code> should return <code>"pony"</code>.'');'
testString: 'assert(checkObj("gift") === "pony", "<code>checkObj("gift")</code> should return <code>"pony"</code>.");'
- text: <code>checkObj("pet")</code> should return <code>"kitten"</code>.
testString: 'assert(checkObj("pet") === "kitten", ''<code>checkObj("pet")</code> should return <code>"kitten"</code>.'');'
testString: 'assert(checkObj("pet") === "kitten", "<code>checkObj("pet")</code> should return <code>"kitten"</code>.");'
- text: <code>checkObj("house")</code> should return <code>"Not Found"</code>.
testString: 'assert(checkObj("house") === "Not Found", ''<code>checkObj("house")</code> should return <code>"Not Found"</code>.'');'
testString: 'assert(checkObj("house") === "Not Found", "<code>checkObj("house")</code> should return <code>"Not Found"</code>.");'
```
@@ -47,7 +47,7 @@ var myObj = {
function checkObj(checkProp) {
// Your Code Here
return "Change Me!";
}

View File

@@ -24,9 +24,9 @@ Correct the assignment to <code>myStr</code> so it contains the string value of
```yml
tests:
- text: <code>myStr</code> should have a value of <code>Hello World</code>
testString: 'assert(myStr === "Hello World", ''<code>myStr</code> should have a value of <code>Hello World</code>'');'
testString: 'assert(myStr === "Hello World", "<code>myStr</code> should have a value of <code>Hello World</code>");'
- text: Do not change the code above the line
testString: 'assert(/myStr = "Jello World"/.test(code), ''Do not change the code above the line'');'
testString: 'assert(/myStr = "Jello World"/.test(code), "Do not change the code above the line");'
```

View File

@@ -21,9 +21,9 @@ Modify the <code>welcomeToBooleans</code> function so that it returns <code>true
```yml
tests:
- text: 'The <code>welcomeToBooleans()</code> function should return a boolean &#40;true/false&#41; value.'
testString: 'assert(typeof welcomeToBooleans() === ''boolean'', ''The <code>welcomeToBooleans()</code> function should return a boolean &#40;true/false&#41; value.'');'
testString: 'assert(typeof welcomeToBooleans() === "boolean", "The <code>welcomeToBooleans()</code> function should return a boolean &#40;true/false&#41; value.");'
- text: <code>welcomeToBooleans()</code> should return true.
testString: 'assert(welcomeToBooleans() === true, ''<code>welcomeToBooleans()</code> should return true.'');'
testString: 'assert(welcomeToBooleans() === true, "<code>welcomeToBooleans()</code> should return true.");'
```

View File

@@ -25,17 +25,17 @@ Modify the existing declarations and assignments so their names use <dfn>camelCa
```yml
tests:
- text: <code>studlyCapVar</code> is defined and has a value of <code>10</code>
testString: 'assert(typeof studlyCapVar !== ''undefined'' && studlyCapVar === 10, ''<code>studlyCapVar</code> is defined and has a value of <code>10</code>'');'
testString: 'assert(typeof studlyCapVar !== "undefined" && studlyCapVar === 10, "<code>studlyCapVar</code> is defined and has a value of <code>10</code>");'
- text: <code>properCamelCase</code> is defined and has a value of <code>"A String"</code>
testString: 'assert(typeof properCamelCase !== ''undefined'' && properCamelCase === "A String", ''<code>properCamelCase</code> is defined and has a value of <code>"A String"</code>'');'
testString: 'assert(typeof properCamelCase !== "undefined" && properCamelCase === "A String", "<code>properCamelCase</code> is defined and has a value of <code>"A String"</code>");'
- text: <code>titleCaseOver</code> is defined and has a value of <code>9000</code>
testString: 'assert(typeof titleCaseOver !== ''undefined'' && titleCaseOver === 9000, ''<code>titleCaseOver</code> is defined and has a value of <code>9000</code>'');'
testString: 'assert(typeof titleCaseOver !== "undefined" && titleCaseOver === 9000, "<code>titleCaseOver</code> is defined and has a value of <code>9000</code>");'
- text: <code>studlyCapVar</code> should use camelCase in both declaration and assignment sections.
testString: 'assert(code.match(/studlyCapVar/g).length === 2, ''<code>studlyCapVar</code> should use camelCase in both declaration and assignment sections.'');'
testString: 'assert(code.match(/studlyCapVar/g).length === 2, "<code>studlyCapVar</code> should use camelCase in both declaration and assignment sections.");'
- text: <code>properCamelCase</code> should use camelCase in both declaration and assignment sections.
testString: 'assert(code.match(/properCamelCase/g).length === 2, ''<code>properCamelCase</code> should use camelCase in both declaration and assignment sections.'');'
testString: 'assert(code.match(/properCamelCase/g).length === 2, "<code>properCamelCase</code> should use camelCase in both declaration and assignment sections.");'
- text: <code>titleCaseOver</code> should use camelCase in both declaration and assignment sections.
testString: 'assert(code.match(/titleCaseOver/g).length === 2, ''<code>titleCaseOver</code> should use camelCase in both declaration and assignment sections.'');'
testString: 'assert(code.match(/titleCaseOver/g).length === 2, "<code>titleCaseOver</code> should use camelCase in both declaration and assignment sections.");'
```

View File

@@ -23,13 +23,13 @@ Create a function <code>addFive</code> without any arguments. This function adds
```yml
tests:
- text: <code>addFive</code> should be a function
testString: 'assert(typeof addFive === ''function'', ''<code>addFive</code> should be a function'');'
testString: 'assert(typeof addFive === "function", "<code>addFive</code> should be a function");'
- text: <code>sum</code> should be equal to 8
testString: 'assert(sum === 8, ''<code>sum</code> should be equal to 8'');'
testString: 'assert(sum === 8, "<code>sum</code> should be equal to 8");'
- text: Returned value from <code>addFive</code> should be <code>undefined</code>
testString: 'assert(addFive() === undefined, ''Returned value from <code>addFive</code> should be <code>undefined</code>'');'
testString: 'assert(addFive() === undefined, "Returned value from <code>addFive</code> should be <code>undefined</code>");'
- text: 'Inside of your functions, add 5 to the <code>sum</code> variable'
testString: 'assert(code.match(/(sum\s*\=\s*sum\s*\+\s*5)|(sum\s*\+\=\s*5)/g).length === 1, ''Inside of your functions, add 5 to the <code>sum</code> variable'');'
testString: 'assert(code.match(/(sum\s*\=\s*sum\s*\+\s*5)|(sum\s*\+\=\s*5)/g).length === 1, "Inside of your functions, add 5 to the <code>sum</code> variable");'
```

View File

@@ -20,13 +20,13 @@ Initialize the three variables <code>a</code>, <code>b</code>, and <code>c</code
```yml
tests:
- text: <code>a</code> should be defined and evaluated to have the value of <code>6</code>
testString: 'assert(typeof a === ''number'' && a === 6, ''<code>a</code> should be defined and evaluated to have the value of <code>6</code>'');'
testString: 'assert(typeof a === "number" && a === 6, "<code>a</code> should be defined and evaluated to have the value of <code>6</code>");'
- text: <code>b</code> should be defined and evaluated to have the value of <code>15</code>
testString: 'assert(typeof b === ''number'' && b === 15, ''<code>b</code> should be defined and evaluated to have the value of <code>15</code>'');'
testString: 'assert(typeof b === "number" && b === 15, "<code>b</code> should be defined and evaluated to have the value of <code>15</code>");'
- text: <code>c</code> should not contain <code>undefined</code> and should have a value of "I am a String!"
testString: 'assert(!/undefined/.test(c) && c === "I am a String!", ''<code>c</code> should not contain <code>undefined</code> and should have a value of "I am a String!"'');'
testString: 'assert(!/undefined/.test(c) && c === "I am a String!", "<code>c</code> should not contain <code>undefined</code> and should have a value of "I am a String!"");'
- text: Do not change code below the line
testString: 'assert(/a = a \+ 1;/.test(code) && /b = b \+ 5;/.test(code) && /c = c \+ " String!";/.test(code), ''Do not change code below the line'');'
testString: 'assert(/a = a \+ 1;/.test(code) && /b = b \+ 5;/.test(code) && /c = c \+ " String!";/.test(code), "Do not change code below the line");'
```

View File

@@ -26,9 +26,9 @@ Update the <code>myDog</code> object's name property. Let's change her name from
```yml
tests:
- text: Update <code>myDog</code>&apos;s <code>"name"</code> property to equal "Happy Coder".
testString: 'assert(/happy coder/gi.test(myDog.name), ''Update <code>myDog</code>&apos;s <code>"name"</code> property to equal "Happy Coder".'');'
testString: 'assert(/happy coder/gi.test(myDog.name), "Update <code>myDog</code>&apos;s <code>"name"</code> property to equal "Happy Coder".");'
- text: Do not edit the <code>myDog</code> definition
testString: 'assert(/"name": "Coder"/.test(code), ''Do not edit the <code>myDog</code> definition'');'
testString: 'assert(/"name": "Coder"/.test(code), "Do not edit the <code>myDog</code> definition");'
```

View File

@@ -23,9 +23,9 @@ Use <dfn>bracket notation</dfn> to find the first character in the <code>lastNam
```yml
tests:
- text: The <code>firstLetterOfLastName</code> variable should have the value of <code>L</code>.
testString: 'assert(firstLetterOfLastName === ''L'', ''The <code>firstLetterOfLastName</code> variable should have the value of <code>L</code>.'');'
testString: 'assert(firstLetterOfLastName === "L", "The <code>firstLetterOfLastName</code> variable should have the value of <code>L</code>.");'
- text: You should use bracket notation.
testString: 'assert(code.match(/firstLetterOfLastName\s*?=\s*?lastName\[.*?\]/), ''You should use bracket notation.'');'
testString: 'assert(code.match(/firstLetterOfLastName\s*?=\s*?lastName\[.*?\]/), "You should use bracket notation.");'
```

View File

@@ -22,9 +22,9 @@ Use <dfn>bracket notation</dfn> to find the last character in the <code>lastName
```yml
tests:
- text: <code>lastLetterOfLastName</code> should be "e".
testString: 'assert(lastLetterOfLastName === "e", ''<code>lastLetterOfLastName</code> should be "e".'');'
testString: 'assert(lastLetterOfLastName === "e", "<code>lastLetterOfLastName</code> should be "e".");'
- text: You have to use <code>.length</code> to get the last letter.
testString: 'assert(code.match(/\.length/g).length === 2, ''You have to use <code>.length</code> to get the last letter.'');'
testString: 'assert(code.match(/\.length/g).length === 2, "You have to use <code>.length</code> to get the last letter.");'
```

View File

@@ -22,9 +22,9 @@ Let's try to set <code>thirdLetterOfLastName</code> to equal the third letter of
```yml
tests:
- text: The <code>thirdLetterOfLastName</code> variable should have the value of <code>v</code>.
testString: 'assert(thirdLetterOfLastName === ''v'', ''The <code>thirdLetterOfLastName</code> variable should have the value of <code>v</code>.'');'
testString: 'assert(thirdLetterOfLastName === "v", "The <code>thirdLetterOfLastName</code> variable should have the value of <code>v</code>.");'
- text: You should use bracket notation.
testString: 'assert(code.match(/thirdLetterOfLastName\s*?=\s*?lastName\[.*?\]/), ''You should use bracket notation.'');'
testString: 'assert(code.match(/thirdLetterOfLastName\s*?=\s*?lastName\[.*?\]/), "You should use bracket notation.");'
```

View File

@@ -22,9 +22,9 @@ Use <dfn>bracket notation</dfn> to find the second-to-last character in the <cod
```yml
tests:
- text: <code>secondToLastLetterOfLastName</code> should be "c".
testString: 'assert(secondToLastLetterOfLastName === ''c'', ''<code>secondToLastLetterOfLastName</code> should be "c".'');'
testString: 'assert(secondToLastLetterOfLastName === "c", "<code>secondToLastLetterOfLastName</code> should be "c".");'
- text: You have to use <code>.length</code> to get the second last letter.
testString: 'assert(code.match(/\.length/g).length === 2, ''You have to use <code>.length</code> to get the second last letter.'');'
testString: 'assert(code.match(/\.length/g).length === 2, "You have to use <code>.length</code> to get the second last letter.");'
```

View File

@@ -26,15 +26,15 @@ Create an <code>if</code> statement inside the function to return <code>"Yes, th
```yml
tests:
- text: <code>trueOrFalse</code> should be a function
testString: 'assert(typeof trueOrFalse === "function", ''<code>trueOrFalse</code> should be a function'');'
testString: 'assert(typeof trueOrFalse === "function", "<code>trueOrFalse</code> should be a function");'
- text: <code>trueOrFalse(true)</code> should return a string
testString: 'assert(typeof trueOrFalse(true) === "string", ''<code>trueOrFalse(true)</code> should return a string'');'
testString: 'assert(typeof trueOrFalse(true) === "string", "<code>trueOrFalse(true)</code> should return a string");'
- text: <code>trueOrFalse(false)</code> should return a string
testString: 'assert(typeof trueOrFalse(false) === "string", ''<code>trueOrFalse(false)</code> should return a string'');'
testString: 'assert(typeof trueOrFalse(false) === "string", "<code>trueOrFalse(false)</code> should return a string");'
- text: '<code>trueOrFalse(true)</code> should return "Yes, that was true"'
testString: 'assert(trueOrFalse(true) === "Yes, that was true", ''<code>trueOrFalse(true)</code> should return "Yes, that was true"'');'
testString: 'assert(trueOrFalse(true) === "Yes, that was true", "<code>trueOrFalse(true)</code> should return "Yes, that was true"");'
- text: '<code>trueOrFalse(false)</code> should return "No, that was false"'
testString: 'assert(trueOrFalse(false) === "No, that was false", ''<code>trueOrFalse(false)</code> should return "No, that was false"'');'
testString: 'assert(trueOrFalse(false) === "No, that was false", "<code>trueOrFalse(false)</code> should return "No, that was false"");'
```
@@ -48,7 +48,7 @@ tests:
```js
// Example
function ourTrueOrFalse(isItTrue) {
if (isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
@@ -58,9 +58,9 @@ function ourTrueOrFalse(isItTrue) {
function trueOrFalse(wasThatTrue) {
// Only change code below this line.
// Only change code above this line.
}

Some files were not shown because too many files have changed in this diff Show More