fix(curriculum): changed test text to use should for JavaScript Algorithms and Data Structures (#37761)
* fix: corrected typo Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
committed by
Oliver Eyton-Williams
parent
9886cf7ca2
commit
2c15bcbb43
@ -46,9 +46,9 @@ Retrieve the second tree from the variable <code>myPlants</code> using object do
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>secondTree</code> should equal "pine"
|
||||
- text: <code>secondTree</code> should equal "pine".
|
||||
testString: assert(secondTree === "pine");
|
||||
- text: Use dot and bracket notation to access <code>myPlants</code>
|
||||
- text: Your code should use dot and bracket notation to access <code>myPlants</code>.
|
||||
testString: assert(/=\s*myPlants\[1\].list\[1\]/.test(code));
|
||||
|
||||
```
|
||||
|
@ -40,9 +40,9 @@ Access the <code>myStorage</code> object and assign the contents of the <code>gl
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>gloveBoxContents</code> should equal "maps"
|
||||
- text: <code>gloveBoxContents</code> should equal "maps".
|
||||
testString: assert(gloveBoxContents === "maps");
|
||||
- text: Use dot and bracket notation to access <code>myStorage</code>
|
||||
- text: Your code should use dot and bracket notation to access <code>myStorage</code>.
|
||||
testString: assert(/=\s*myStorage\.car\.inside\[\s*("|')glove box\1\s*\]/g.test(code));
|
||||
|
||||
```
|
||||
|
@ -26,9 +26,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>.
|
||||
- text: You should add the property <code>"bark"</code> to <code>myDog</code>.
|
||||
testString: assert(myDog.bark !== undefined);
|
||||
- text: Do not add <code>"bark"</code> to the setup section
|
||||
- text: You should not add <code>"bark"</code> to the setup section.
|
||||
testString: assert(!/bark[^\n]:/.test(code));
|
||||
|
||||
```
|
||||
|
@ -29,9 +29,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>
|
||||
- text: <code>sum</code> should equal <code>20</code>.
|
||||
testString: assert(sum === 20);
|
||||
- text: Use the <code>+</code> operator
|
||||
- text: You should use the <code>+</code> operator.
|
||||
testString: assert(/\+/.test(code));
|
||||
|
||||
```
|
||||
|
@ -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
|
||||
- text: <code>someAdjective</code> should be set to a string at least 3 characters long.
|
||||
testString: assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);
|
||||
- text: Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator
|
||||
- text: You should append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator.
|
||||
testString: assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
|
||||
|
||||
```
|
||||
|
@ -36,9 +36,9 @@ Try creating one of each type of comment.
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: Create a <code>//</code> style comment that contains at least five letters.
|
||||
- text: You should create a <code>//</code> style comment that contains at least five letters.
|
||||
testString: assert(code.match(/(\/\/)...../g));
|
||||
- text: Create a <code>/* */</code> style comment that contains at least five letters.
|
||||
- text: You should create a <code>/* */</code> style comment that contains at least five letters.
|
||||
testString: assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm));
|
||||
|
||||
```
|
||||
|
@ -31,15 +31,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>
|
||||
- text: <code>a</code> should equal <code>15</code>.
|
||||
testString: assert(a === 15);
|
||||
- text: <code>b</code> should equal <code>26</code>
|
||||
- text: <code>b</code> should equal <code>26</code>.
|
||||
testString: assert(b === 26);
|
||||
- text: <code>c</code> should equal <code>19</code>
|
||||
- text: <code>c</code> should equal <code>19</code>.
|
||||
testString: assert(c === 19);
|
||||
- text: You should use the <code>+=</code> operator for each variable
|
||||
- text: You should use the <code>+=</code> operator for each variable.
|
||||
testString: assert(code.match(/\+=/g).length === 3);
|
||||
- text: Do not modify the code above the line
|
||||
- text: You should not modify the code above the specified comment.
|
||||
testString: assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code));
|
||||
|
||||
```
|
||||
|
@ -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>4</code>
|
||||
- text: <code>a</code> should equal <code>4</code>.
|
||||
testString: assert(a === 4);
|
||||
- text: <code>b</code> should equal <code>27</code>
|
||||
- text: <code>b</code> should equal <code>27</code>.
|
||||
testString: assert(b === 27);
|
||||
- text: <code>c</code> should equal <code>3</code>
|
||||
- text: <code>c</code> should equal <code>3</code>.
|
||||
testString: assert(c === 3);
|
||||
- text: You should use the <code>/=</code> operator for each variable
|
||||
- text: You should use the <code>/=</code> operator for each variable.
|
||||
testString: assert(code.match(/\/=/g).length === 3);
|
||||
- text: Do not modify the code above the line
|
||||
- text: You should not modify the code above the specified comment.
|
||||
testString: assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code));
|
||||
|
||||
```
|
||||
|
@ -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>25</code>
|
||||
- text: <code>a</code> should equal <code>25</code>.
|
||||
testString: assert(a === 25);
|
||||
- text: <code>b</code> should equal <code>36</code>
|
||||
- text: <code>b</code> should equal <code>36</code>.
|
||||
testString: assert(b === 36);
|
||||
- text: <code>c</code> should equal <code>46</code>
|
||||
- text: <code>c</code> should equal <code>46</code>.
|
||||
testString: assert(c === 46);
|
||||
- text: You should use the <code>*=</code> operator for each variable
|
||||
- text: You should use the <code>*=</code> operator for each variable.
|
||||
testString: assert(code.match(/\*=/g).length === 3);
|
||||
- text: Do not modify the code above the line
|
||||
- text: You should not modify the code above the specified comment.
|
||||
testString: assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\.6;/.test(code));
|
||||
|
||||
```
|
||||
|
@ -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>5</code>
|
||||
- text: <code>a</code> should equal <code>5</code>.
|
||||
testString: assert(a === 5);
|
||||
- text: <code>b</code> should equal <code>-6</code>
|
||||
- text: <code>b</code> should equal <code>-6</code>.
|
||||
testString: assert(b === -6);
|
||||
- text: <code>c</code> should equal <code>2</code>
|
||||
- text: <code>c</code> should equal <code>2</code>.
|
||||
testString: assert(c === 2);
|
||||
- text: You should use the <code>-=</code> operator for each variable
|
||||
- text: You should use the <code>-=</code> operator for each variable.
|
||||
testString: assert(code.match(/-=/g).length === 3);
|
||||
- text: Do not modify the code above the line
|
||||
- text: You should not modify the code above the specified comment.
|
||||
testString: assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code));
|
||||
|
||||
```
|
||||
|
@ -30,11 +30,11 @@ Build <code>myStr</code> from the strings <code>"This is the start. "</code> and
|
||||
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.");
|
||||
- text: Use the <code>+</code> operator to build <code>myStr</code>
|
||||
- text: You should use the <code>+</code> operator to build <code>myStr</code>.
|
||||
testString: assert(code.match(/(["']).*(["'])\s*\+\s*(["']).*(["'])/g).length > 1);
|
||||
- text: <code>myStr</code> should be created using the <code>var</code> keyword.
|
||||
testString: assert(/var\s+myStr/.test(code));
|
||||
- text: Make sure to assign the result to the <code>myStr</code> variable.
|
||||
- text: You should assign the result to the <code>myStr</code> variable.
|
||||
testString: assert(/myStr\s*=/.test(code));
|
||||
|
||||
```
|
||||
|
@ -24,7 +24,7 @@ Build <code>myStr</code> over several lines by concatenating these two strings:
|
||||
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.");
|
||||
- text: Use the <code>+=</code> operator to build <code>myStr</code>
|
||||
- text: You should 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);
|
||||
|
||||
```
|
||||
|
@ -21,9 +21,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
|
||||
- text: <code>myName</code> should be set to a string at least 3 characters long.
|
||||
testString: assert(typeof myName !== 'undefined' && myName.length > 2);
|
||||
- text: Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it
|
||||
- text: You should 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);
|
||||
|
||||
```
|
||||
|
@ -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>10</code>
|
||||
- text: <code>myVar</code> should equal <code>10</code>.
|
||||
testString: assert(myVar === 10);
|
||||
- text: <code>myVar = myVar - 1;</code> should be changed
|
||||
- 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));
|
||||
- text: Use the <code>--</code> operator on <code>myVar</code>
|
||||
- text: You should use the <code>--</code> operator on <code>myVar</code>.
|
||||
testString: assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code));
|
||||
- text: Do not change code above the line
|
||||
- text: You should not change code above the specified comment.
|
||||
testString: assert(/var myVar = 11;/.test(code));
|
||||
|
||||
```
|
||||
|
@ -22,9 +22,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>.
|
||||
- text: You should delete the property <code>"tails"</code> from <code>myDog</code>.
|
||||
testString: assert(typeof myDog === "object" && myDog.tails === undefined);
|
||||
- text: Do not modify the <code>myDog</code> setup
|
||||
- text: You should not modify the <code>myDog</code> setup.
|
||||
testString: 'assert(code.match(/"tails": 1/g).length > 1);'
|
||||
|
||||
```
|
||||
|
@ -30,9 +30,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.
|
||||
- text: The variable <code>quotient</code> should be equal to 2.
|
||||
testString: assert(quotient === 2);
|
||||
- text: Use the <code>/</code> operator
|
||||
- text: You should use the <code>/</code> operator.
|
||||
testString: assert(/\d+\s*\/\s*\d+/.test(code));
|
||||
|
||||
```
|
||||
|
@ -32,11 +32,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>
|
||||
- text: You should not change the value of the global <code>outerWear</code>.
|
||||
testString: assert(outerWear === "T-Shirt");
|
||||
- text: <code>myOutfit</code> should return <code>"sweater"</code>
|
||||
- text: <code>myOutfit</code> should return <code>"sweater"</code>.
|
||||
testString: assert(myOutfit() === "sweater");
|
||||
- text: Do not change the return statement
|
||||
- text: You should not change the return statement.
|
||||
testString: assert(/return outerWear/.test(code));
|
||||
|
||||
```
|
||||
|
@ -26,13 +26,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>
|
||||
- text: <code>myVar</code> should equal <code>88</code>.
|
||||
testString: assert(myVar === 88);
|
||||
- text: <code>myVar = myVar + 1;</code> should be changed
|
||||
- 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));
|
||||
- text: Use the <code>++</code> operator
|
||||
- text: You should use the <code>++</code> operator.
|
||||
testString: assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code));
|
||||
- text: Do not change code above the line
|
||||
- text: You should not change code above the specified comment.
|
||||
testString: assert(/var myVar = 87;/.test(code));
|
||||
|
||||
```
|
||||
|
@ -23,7 +23,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>
|
||||
- text: You should initialize <code>a</code> to a value of <code>9</code>.
|
||||
testString: assert(/var\s+a\s*=\s*9\s*/.test(code));
|
||||
|
||||
```
|
||||
|
@ -40,9 +40,9 @@ tests:
|
||||
testString: assert(testElse(5) === "5 or Smaller");
|
||||
- text: <code>testElse(6)</code> should return "Bigger than 5"
|
||||
testString: assert(testElse(6) === "Bigger than 5");
|
||||
- text: <code>testElse(10)</code> should return "Bigger than 5"
|
||||
- text: <code>testElse(10)</code> should return "Bigger than 5".
|
||||
testString: assert(testElse(10) === "Bigger than 5");
|
||||
- text: Do not change the code above or below the lines.
|
||||
- text: You should not change the code above or below the specified comments.
|
||||
testString: assert(/var result = "";/.test(code) && /return result;/.test(code));
|
||||
|
||||
```
|
||||
|
@ -30,13 +30,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
|
||||
- text: <code>total</code> should be declared and initialized to 0.
|
||||
testString: assert(code.match(/(var|let|const)\s*?total\s*=\s*0.*?;?/));
|
||||
- text: <code>total</code> should equal 20
|
||||
- text: <code>total</code> should equal 20.
|
||||
testString: assert(total === 20);
|
||||
- text: You should use a <code>for</code> loop to iterate through <code>myArr</code>
|
||||
- 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*\[/));
|
||||
- text: Do not set <code>total</code> to 20 directly
|
||||
- text: You should not set <code>total</code> to 20 directly.
|
||||
testString: assert(!code.match(/total[\s\+\-]*=\s*(0(?!\s*[;,]?$)|[1-9])/gm));
|
||||
```
|
||||
|
||||
|
@ -34,9 +34,9 @@ Declare a local variable <code>myVar</code> inside <code>myLocalScope</code>. Ru
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: No global <code>myVar</code> variable
|
||||
- text: The code should not contain a global <code>myVar</code> variable.
|
||||
testString: assert(typeof myVar === 'undefined');
|
||||
- text: Add a local <code>myVar</code> variable
|
||||
- text: You should add a local <code>myVar</code> variable.
|
||||
testString: assert(/function\s+myLocalScope\s*\(\s*\)\s*\{\s[\s\S]+\s*var\s*myVar\s*(\s*|=[\s\S]+)\s*;[\s\S]+}/.test(code));
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ Use the <code>.pop()</code> function to remove the last item from <code>myArray<
|
||||
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));
|
||||
- text: Use <code>pop()</code> on <code>myArray</code>
|
||||
- text: You should use <code>pop()</code> on <code>myArray</code>.
|
||||
testString: assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(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));
|
||||
|
@ -30,9 +30,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
|
||||
- text: The variable <code>product</code> should be equal to 80.
|
||||
testString: assert(product === 80);
|
||||
- text: Use the <code>*</code> operator
|
||||
- text: You should use the <code>*</code> operator.
|
||||
testString: assert(/\*/.test(code));
|
||||
|
||||
```
|
||||
|
@ -32,13 +32,13 @@ We have passed two arguments, <code>"Hello"</code> and <code>"World"</code>. Ins
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>functionWithArgs</code> should be a function
|
||||
- text: <code>functionWithArgs</code> should be a function.
|
||||
testString: assert(typeof functionWithArgs === 'function');
|
||||
- text: <code>functionWithArgs(1,2)</code> should output <code>3</code>
|
||||
- text: <code>functionWithArgs(1,2)</code> should output <code>3</code>.
|
||||
testString: if(typeof functionWithArgs === "function") { capture(); functionWithArgs(1,2); uncapture(); } assert(logOutput == 3);
|
||||
- text: <code>functionWithArgs(7,9)</code> should output <code>16</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);
|
||||
- text: Call <code>functionWithArgs</code> with two numbers after you define it.
|
||||
- text: You should 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));
|
||||
|
||||
```
|
||||
|
@ -43,9 +43,9 @@ Right now, the <code><a></code> tag in the string uses double quotes eve
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: Remove all the <code>backslashes</code> (<code>\</code>)
|
||||
- text: You should 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*'));
|
||||
- text: You should have two single quotes <code>'</code> and four double quotes <code>"</code>
|
||||
- text: You should have two single quotes <code>'</code> and four double quotes <code>"</code>.
|
||||
testString: assert(code.match(/"/g).length === 4 && code.match(/'/g).length === 2);
|
||||
|
||||
```
|
||||
|
@ -24,13 +24,13 @@ There should be at least 5 sub-arrays in the list.
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myList</code> should be an array
|
||||
- text: <code>myList</code> should be an array.
|
||||
testString: assert(isArray);
|
||||
- text: The first elements in each of your sub-arrays must all be strings
|
||||
- text: The first elements in each of your sub-arrays should all be strings.
|
||||
testString: assert(hasString);
|
||||
- text: The second elements in each of your sub-arrays must all be numbers
|
||||
- text: The second elements in each of your sub-arrays should all be numbers.
|
||||
testString: assert(hasNumber);
|
||||
- text: You must have at least 5 items in your list
|
||||
- text: You should have at least 5 items in your list.
|
||||
testString: assert(count > 4);
|
||||
|
||||
```
|
||||
|
@ -32,13 +32,13 @@ Assign the contents of <code>a</code> to variable <code>b</code>.
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: Do not change code above the line
|
||||
- text: You should not change code above the specified comment.
|
||||
testString: assert(/var a;/.test(code) && /var b = 2;/.test(code));
|
||||
- text: <code>a</code> should have a value of 7
|
||||
- text: <code>a</code> should have a value of 7.
|
||||
testString: assert(typeof a === 'number' && a === 7);
|
||||
- text: <code>b</code> should have a value of 7
|
||||
- text: <code>b</code> should have a value of 7.
|
||||
testString: assert(typeof b === 'number' && b === 7);
|
||||
- text: <code>a</code> should be assigned to <code>b</code> with <code>=</code>
|
||||
- text: <code>a</code> should be assigned to <code>b</code> with <code>=</code>.
|
||||
testString: assert(/b\s*=\s*a\s*;/g.test(code));
|
||||
|
||||
```
|
||||
|
@ -30,9 +30,9 @@ Change the <code>0</code> so the difference is <code>12</code>.
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: Make the variable <code>difference</code> equal 12.
|
||||
- text: The variable <code>difference</code> should be equal to 12.
|
||||
testString: assert(difference === 12);
|
||||
- text: Only subtract one number from 45.
|
||||
- text: You should 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));
|
||||
|
||||
```
|
||||
|
@ -35,9 +35,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>
|
||||
- text: <code>myStr</code> should have a value of <code>Hello World</code>.
|
||||
testString: assert(myStr === "Hello World");
|
||||
- text: Do not change the code above the line
|
||||
- text: You should not change the code above the specified comment.
|
||||
testString: assert(/myStr = "Jello World"/.test(code));
|
||||
|
||||
```
|
||||
|
@ -32,11 +32,11 @@ 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>
|
||||
- text: <code>studlyCapVar</code> should be defined and have a value of <code>10</code>.
|
||||
testString: assert(typeof studlyCapVar !== 'undefined' && studlyCapVar === 10);
|
||||
- text: <code>properCamelCase</code> is defined and has a value of <code>"A String"</code>
|
||||
- text: <code>properCamelCase</code> should be defined and have a value of <code>"A String"</code>.
|
||||
testString: assert(typeof properCamelCase !== 'undefined' && properCamelCase === "A String");
|
||||
- text: <code>titleCaseOver</code> is defined and has a value of <code>9000</code>
|
||||
- text: <code>titleCaseOver</code> should be defined and have a value of <code>9000</code>.
|
||||
testString: assert(typeof titleCaseOver !== 'undefined' && titleCaseOver === 9000);
|
||||
- text: <code>studlyCapVar</code> should use camelCase in both declaration and assignment sections.
|
||||
testString: assert(code.match(/studlyCapVar/g).length === 2);
|
||||
|
@ -32,13 +32,13 @@ Create a function <code>addFive</code> without any arguments. This function adds
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>addFive</code> should be a function
|
||||
- text: <code>addFive</code> should be a function.
|
||||
testString: assert(typeof addFive === 'function');
|
||||
- text: Once both functions have ran, the <code>sum</code> should be equal to 8
|
||||
- text: Once both functions have ran, the <code>sum</code> should be equal to 8.
|
||||
testString: assert(sum === 8);
|
||||
- text: Returned value from <code>addFive</code> should be <code>undefined</code>
|
||||
- text: Returned value from <code>addFive</code> should be <code>undefined</code>.
|
||||
testString: assert(addFive() === undefined);
|
||||
- text: Inside the <code>addFive</code> function, add <code>5</code> to the <code>sum</code> variable
|
||||
- text: Inside the <code>addFive</code> function, you should add <code>5</code> to the <code>sum</code> variable.
|
||||
testString: assert(addFive.toString().replace(/\s/g, '').match(/sum=sum\+5|sum\+=5/));
|
||||
|
||||
```
|
||||
|
@ -21,13 +21,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>
|
||||
- text: <code>a</code> should be defined and evaluated to have the value of <code>6</code>.
|
||||
testString: assert(typeof a === 'number' && a === 6);
|
||||
- text: <code>b</code> should be defined and evaluated to have the value of <code>15</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);
|
||||
- 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!");
|
||||
- text: Do not change code below the line
|
||||
- text: You should not change code below the specified comment.
|
||||
testString: assert(/a = a \+ 1;/.test(code) && /b = b \+ 5;/.test(code) && /c = c \+ " String!";/.test(code));
|
||||
|
||||
```
|
||||
|
@ -36,9 +36,9 @@ Update the <code>myDog</code> object's name property. Let's change her name from
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: Update <code>myDog</code>'s <code>"name"</code> property to equal "Happy Coder".
|
||||
- text: You should update <code>myDog</code>'s <code>"name"</code> property to equal "Happy Coder".
|
||||
testString: assert(/happy coder/gi.test(myDog.name));
|
||||
- text: Do not edit the <code>myDog</code> definition
|
||||
- text: You should not edit the <code>myDog</code> definition.
|
||||
testString: 'assert(/"name": "Coder"/.test(code));'
|
||||
|
||||
```
|
||||
|
@ -25,7 +25,7 @@ Use <dfn>bracket notation</dfn> to find the last character in the <code>lastName
|
||||
tests:
|
||||
- text: <code>lastLetterOfLastName</code> should be "e".
|
||||
testString: assert(lastLetterOfLastName === "e");
|
||||
- text: You have to use <code>.length</code> to get the last letter.
|
||||
- text: You should use <code>.length</code> to get the last letter.
|
||||
testString: assert(code.match(/\.length/g).length === 2);
|
||||
|
||||
```
|
||||
|
@ -25,7 +25,7 @@ Use <dfn>bracket notation</dfn> to find the second-to-last character in the <cod
|
||||
tests:
|
||||
- text: <code>secondToLastLetterOfLastName</code> should be "c".
|
||||
testString: assert(secondToLastLetterOfLastName === 'c');
|
||||
- text: You have to use <code>.length</code> to get the second last letter.
|
||||
- text: You should use <code>.length</code> to get the second last letter.
|
||||
testString: assert(code.match(/\.length/g).length === 2);
|
||||
|
||||
```
|
||||
|
@ -32,11 +32,11 @@ Each time the function is called it will print out the message <code>"Hello Worl
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>reusableFunction</code> should be a function
|
||||
- text: <code>reusableFunction</code> should be a function.
|
||||
testString: assert(typeof reusableFunction === 'function');
|
||||
- text: <code>reusableFunction</code> should output "Hi World" to the dev console
|
||||
- text: <code>reusableFunction</code> should output "Hi World" to the dev console.
|
||||
testString: assert(hiWorldWasLogged);
|
||||
- text: Call <code>reusableFunction</code> after you define it
|
||||
- text: You should call <code>reusableFunction</code> after you define it.
|
||||
testString: assert(/^\s*reusableFunction\(\)\s*/m.test(code));
|
||||
|
||||
```
|
||||
|
Reference in New Issue
Block a user