mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix: remove comments from user code before test (#55113)
This commit is contained in:
committed by
GitHub
parent
f8d88586c3
commit
f6e50ac7b9
+4
-4
@@ -28,25 +28,25 @@ _Note_: It is common practice to end statements in JavaScript with a semicolon.
|
||||
You should use `let` in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /let/);
|
||||
assert.match(__helpers.removeJSComments(code), /let/);
|
||||
```
|
||||
|
||||
You should use `character` in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /character/);
|
||||
assert.match(__helpers.removeJSComments(code), /character/);
|
||||
```
|
||||
|
||||
You should use `let` to declare a `character` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+character/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+character/);
|
||||
```
|
||||
|
||||
Your declaration should end with a semi-colon.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+character;/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+character;/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -22,19 +22,19 @@ Initialize your `character` variable by assigning it the value `"Hello"` during
|
||||
You should use the assignment operator `=`.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+character\s*=/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+character\s*=/);
|
||||
```
|
||||
|
||||
You should use the string `"Hello"`.
|
||||
|
||||
```js
|
||||
assert.match(code, /('|")Hello\1/);
|
||||
assert.match(__helpers.removeJSComments(code), /('|")Hello\1/);
|
||||
```
|
||||
|
||||
You should use double quotes for your `"Hello"` string.
|
||||
|
||||
```js
|
||||
assert.match(code, /"Hello"/);
|
||||
assert.match(__helpers.removeJSComments(code), /"Hello"/);
|
||||
```
|
||||
|
||||
You should assign `"Hello"` to your `character` variable.
|
||||
|
||||
+4
-4
@@ -18,25 +18,25 @@ Change your `"Hello"` string to use single quotes.
|
||||
You should not have double quotes in your code.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /"/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /"/);
|
||||
```
|
||||
|
||||
You should use single quotes for your `"Hello"` string.
|
||||
|
||||
```js
|
||||
assert.match(code, /'Hello'/);
|
||||
assert.match(__helpers.removeJSComments(code), /'Hello'/);
|
||||
```
|
||||
|
||||
You should still use `let` in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /let/);
|
||||
assert.match(__helpers.removeJSComments(code), /let/);
|
||||
```
|
||||
|
||||
You should still declare a `character` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+character/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+character/);
|
||||
```
|
||||
|
||||
Your `character` variable should still have the string `"Hello"` for its value.
|
||||
|
||||
+4
-4
@@ -23,25 +23,25 @@ Print the value of the `character` variable to the console. Then, click the "Con
|
||||
You should access the `console` in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /console/);
|
||||
assert.match(__helpers.removeJSComments(code), /console/);
|
||||
```
|
||||
|
||||
You should access the `log` property of the `console`.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log/);
|
||||
```
|
||||
|
||||
You should use parentheses to call the `.log()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(/);
|
||||
```
|
||||
|
||||
You should print the `character` variable to the console.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*character\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*character\s*\)/);
|
||||
```
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -23,19 +23,19 @@ After your `console.log`, assign the value `"World"` to your `character` variabl
|
||||
You should use `character` twice in your code.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/character/g), 3);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/character/g), 3);
|
||||
```
|
||||
|
||||
You should use the assignment operator to reassign `character`.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/character\s*\=/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/character\s*\=/g), 2);
|
||||
```
|
||||
|
||||
You should use the string `"World"` in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /("|')World\1/);
|
||||
assert.match(__helpers.removeJSComments(code), /("|')World\1/);
|
||||
```
|
||||
|
||||
Your `character` variable should have the value `"World"`.
|
||||
@@ -47,7 +47,7 @@ assert.equal(character, "World");
|
||||
Your reassignment should not use `let`.
|
||||
|
||||
```js
|
||||
assert.isBelow(code.match(/let/g).length, 2);
|
||||
assert.isBelow(__helpers.removeJSComments(code).match(/let/g).length, 2);
|
||||
```
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -14,20 +14,20 @@ Now log your `character` variable to the console again. You should see the strin
|
||||
You should use `console.log` a second time.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/console\.log/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/console\.log/g), 2);
|
||||
```
|
||||
|
||||
You should log `character` to the console a second time.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/console\.log\(\s*character\s*\)/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/console\.log\(\s*character\s*\)/g), 2);
|
||||
```
|
||||
|
||||
|
||||
Your new `console.log()` should come after your reassignment.
|
||||
|
||||
```js
|
||||
const reassign = code.split(/\n+/).findIndex(l => l.match(/character\s+=\s+("|')World\1/));
|
||||
const reassign = __helpers.removeJSComments(code).split(/\n+/).findIndex(l => l.match(/character\s+=\s+("|')World\1/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -16,13 +16,13 @@ Also remove your `secondCharacter` variable, but leave the `character` initializ
|
||||
You should not have any `console.log()` statements in your code.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /console/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /console/);
|
||||
```
|
||||
|
||||
You should not reassign the value of `character`.
|
||||
|
||||
```js
|
||||
assert.isAtMost(code.match(/character/).length, 1);
|
||||
assert.isAtMost(__helpers.removeJSComments(code).match(/character/).length, 1);
|
||||
```
|
||||
|
||||
Your `character` variable should have the value `"Hello"`.
|
||||
@@ -34,7 +34,7 @@ assert.equal(character, "Hello");
|
||||
You should not have a `secondCharacter` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /secondCharacter/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /secondCharacter/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -18,13 +18,13 @@ let money = 100;
|
||||
You should have a second `let` keyword in your code.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/let/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/let/g), 2);
|
||||
```
|
||||
|
||||
You should use `let` to declare a `count` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+count/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+count/);
|
||||
```
|
||||
|
||||
You should assign the number `8` to your `count` variable.
|
||||
|
||||
+3
-3
@@ -14,19 +14,19 @@ With the `number` data type, you can perform mathematical operations, like addit
|
||||
You should access the `console` in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /console/);
|
||||
assert.match(__helpers.removeJSComments(code), /console/);
|
||||
```
|
||||
|
||||
You should access the `.log()` of the `console`.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log/);
|
||||
```
|
||||
|
||||
You should log `count + 1` to the console.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*count\s*\+\s*1\s*\);?/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*count\s*\+\s*1\s*\);?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ You can also perform subtraction (`-`), multiplication (`*`), and division (`/`)
|
||||
You should not have a `console.log()` in your code.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /console/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /console/);
|
||||
```
|
||||
|
||||
Your `character` variable should still have the value `"Hello"`.
|
||||
|
||||
+2
-2
@@ -24,13 +24,13 @@ Declare a `rows` variable and assign it an empty array.
|
||||
You should have a `rows` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows/);
|
||||
```
|
||||
|
||||
You should use `let` to declare your `rows` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+rows/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+rows/);
|
||||
```
|
||||
|
||||
You should assign an empty array to your `rows` variable.
|
||||
|
||||
+5
-5
@@ -18,31 +18,31 @@ Use `console.log` and bracket notation to print the first value in your `rows` a
|
||||
You should have a `console.log()` statement in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log/);
|
||||
```
|
||||
|
||||
You should access your `rows` array.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/rows/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/rows/g), 2);
|
||||
```
|
||||
|
||||
You should use bracket notation with your `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\[/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\[/);
|
||||
```
|
||||
|
||||
You should use bracket notation to access the first element of your `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\[\s*0\s*\]/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\[\s*0\s*\]/);
|
||||
```
|
||||
|
||||
You should log the first element of your `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*rows\[\s*0\s*]\s*\);?/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*rows\[\s*0\s*]\s*\);?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+5
-5
@@ -24,19 +24,19 @@ Update the **third** element of your `rows` array to be the number `10`. Then pr
|
||||
You should use bracket notation on the `rows` array again.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/rows\[/g), 2)
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/rows\[/g), 2)
|
||||
```
|
||||
|
||||
You should access the third element of the `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\[\s*2\s*\]/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\[\s*2\s*\]/);
|
||||
```
|
||||
|
||||
You should use the assignment operator on the third element of the `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\[\s*2\s*\]\s*=/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\[\s*2\s*\]\s*=/);
|
||||
```
|
||||
|
||||
You should assign the value `10` to the third element of your `rows` array.
|
||||
@@ -48,13 +48,13 @@ assert.equal(rows[2], 10);
|
||||
You should have a second `console.log` statement in your code.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/console\.log/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/console\.log/g), 2);
|
||||
```
|
||||
|
||||
You should log the `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*rows\s*\);?/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*rows\s*\);?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -14,19 +14,19 @@ For now, remove your first console log and your `rows[rows.length - 1]` assignme
|
||||
You should remove your `console.log(rows[0])` statement.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /console\.log\(\s*rows\[\s*0\s*\]\s*\)/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /console\.log\(\s*rows\[\s*0\s*\]\s*\)/);
|
||||
```
|
||||
|
||||
You should remove your `rows[rows.length - 1]` reassignment.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /rows\[\s*rows\.length\s*-\s*1\s*\]/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /rows\[\s*rows\.length\s*-\s*1\s*\]/);
|
||||
```
|
||||
|
||||
You should not remove your `console.log(rows)` statement.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*rows\s*\);/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*rows\s*\);/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -22,19 +22,19 @@ Use `.push()` to add the string `"freeCodeCamp"` to the end of your `rows` array
|
||||
You should use `.push()` in your code.
|
||||
|
||||
```js
|
||||
assert.match(code, /\.push\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /\.push\(/);
|
||||
```
|
||||
|
||||
You should use the `.push()` method of your `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.push\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.push\(/);
|
||||
```
|
||||
|
||||
You should pass the string `"freeCodeCamp"` to your `.push()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.push\(\s*('|")freeCodeCamp\1\s*\);?/)
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.push\(\s*('|")freeCodeCamp\1\s*\);?/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+5
-5
@@ -18,31 +18,31 @@ Create a new variable called `popped` and assign it the result of `rows.pop()`.
|
||||
You should declare a variable called `popped`.
|
||||
|
||||
```js
|
||||
assert.match(code, /popped/);
|
||||
assert.match(__helpers.removeJSComments(code), /popped/);
|
||||
```
|
||||
|
||||
You should use `let` to declare your variable called `popped`.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+popped/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+popped/);
|
||||
```
|
||||
|
||||
You should call the `.pop()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /\.pop\(\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /\.pop\(\s*\)/);
|
||||
```
|
||||
|
||||
You should call the `.pop()` method on your `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.pop\(\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.pop\(\s*\)/);
|
||||
```
|
||||
|
||||
You should log your `popped` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*popped\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*popped\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -16,13 +16,13 @@ But what does `.push()` return? Assign your existing `rows.push()` to a new `pus
|
||||
You should declare a `pushed` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /pushed/);
|
||||
assert.match(__helpers.removeJSComments(code), /pushed/);
|
||||
```
|
||||
|
||||
You should use `let` to declare your `pushed` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+pushed/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+pushed/);
|
||||
```
|
||||
|
||||
You should assign `rows.push("freeCodeCamp")` to your `pushed` variable.
|
||||
@@ -34,7 +34,7 @@ assert.equal(pushed, 4);
|
||||
You should log your `pushed` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*pushed\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*pushed\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+5
-5
@@ -16,31 +16,31 @@ It is important to be aware of what values a method returns. Take some time to e
|
||||
You should not have a `.push()` call.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /\.push\(/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /\.push\(/);
|
||||
```
|
||||
|
||||
You should not have a `.pop()` call.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /.pull\(/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /.pull\(/);
|
||||
```
|
||||
|
||||
You should not have any log statements.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /console\.log/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /console\.log/);
|
||||
```
|
||||
|
||||
You should not have a `popped` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /popped/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /popped/);
|
||||
```
|
||||
|
||||
You should not have a `pushed` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /pushed/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /pushed/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ assert.empty(rows);
|
||||
Your `"Hello"` string should use double quotes.
|
||||
|
||||
```js
|
||||
assert.match(code, /"Hello"/);
|
||||
assert.match(__helpers.removeJSComments(code), /"Hello"/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+4
-4
@@ -31,25 +31,25 @@ Replace your `let` keywords with `const`.
|
||||
You should use `const` to declare your `character` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+character/);
|
||||
assert.match(__helpers.removeJSComments(code), /const\s+character/);
|
||||
```
|
||||
|
||||
You should use `const` to declare your `count` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+count/);
|
||||
assert.match(__helpers.removeJSComments(code), /const\s+count/);
|
||||
```
|
||||
|
||||
You should use `const` to declare your `rows` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+rows/);
|
||||
assert.match(__helpers.removeJSComments(code), /const\s+rows/);
|
||||
```
|
||||
|
||||
You should not use `let` in your code.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /let/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /let/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+5
-5
@@ -25,31 +25,31 @@ In the upcoming steps, you'll explore each component of a loop in detail. For no
|
||||
You should have a `for` loop.
|
||||
|
||||
```js
|
||||
assert.match(code, /for/);
|
||||
assert.match(__helpers.removeJSComments(code), /for/);
|
||||
```
|
||||
|
||||
The first component of your `for` loop should be the string `"iterator"`.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*('|")iterator\1/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*('|")iterator\1/);
|
||||
```
|
||||
|
||||
The second component of your `for` loop should be the string `"condition"`.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2/);
|
||||
```
|
||||
|
||||
The third component of your `for` loop should be the string `"iteration"`.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2\s*;\s*('|")iteration\3\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2\s*;\s*('|")iteration\3\s*\)/);
|
||||
```
|
||||
|
||||
The body of your `for` loop should be empty.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2\s*;\s*('|")iteration\3\s*\)\s*\{\s*\}/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2\s*;\s*('|")iteration\3\s*\)\s*\{\s*\}/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -24,19 +24,19 @@ Replace the string `"iterator"` with a `let` declaration for the variable `i`. A
|
||||
You should use `let` to declare an `i` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+i/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+i/);
|
||||
```
|
||||
|
||||
You should assign `0` to your `i` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+i\s*=\s*0/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+i\s*=\s*0/);
|
||||
```
|
||||
|
||||
Your `for` loop should start an `i` iterator at `0`.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s+i\s*=\s*0/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s+i\s*=\s*0/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -20,19 +20,19 @@ Replace your `"condition"` string with a condition to check if `i` is less than
|
||||
You should use the less than operator.
|
||||
|
||||
```js
|
||||
assert.match(code, /</);
|
||||
assert.match(__helpers.removeJSComments(code), /</);
|
||||
```
|
||||
|
||||
You should use the less than operator to check if `i` is less than `count`.
|
||||
|
||||
```js
|
||||
assert.match(code, /i\s*<\s*count/);
|
||||
assert.match(__helpers.removeJSComments(code), /i\s*<\s*count/);
|
||||
```
|
||||
|
||||
Your `for` loop should use `i < count` as the condition.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -18,19 +18,19 @@ Use that syntax to replace your `"iteration"` string with a reassignment stateme
|
||||
You should add one to your `i` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /i\s*\+\s*1/);
|
||||
assert.match(__helpers.removeJSComments(code), /i\s*\+\s*1/);
|
||||
```
|
||||
|
||||
You should assign `i + 1` back to your `i` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /i\s*=\s*i\s*\+\s*1/);
|
||||
assert.match(__helpers.removeJSComments(code), /i\s*=\s*i\s*\+\s*1/);
|
||||
```
|
||||
|
||||
Your `for` loop should increase `i` by `1` on each iteration.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;\s*i\s*=\s*i\s*\+\s*1\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;\s*i\s*=\s*i\s*\+\s*1\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -14,19 +14,19 @@ Your loop should now run eight times. Inside the body of the loop, print the val
|
||||
You should use `console.log()`.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log/)
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log/)
|
||||
```
|
||||
|
||||
You should log the value of `i`.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*i\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*i\s*\)/);
|
||||
```
|
||||
|
||||
You should log the value of `i` in your `for` loop.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;\s*i\s*=\s*i\s*\+\s*1\s*\)\s*\{\s*console\.log\(\s*i\s*\);?\s*\}/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;\s*i\s*=\s*i\s*\+\s*1\s*\)\s*\{\s*console\.log\(\s*i\s*\);?\s*\}/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+4
-4
@@ -16,25 +16,25 @@ Replace your log statement with a statement to push `i` to your `rows` array.
|
||||
You should not have a `console.log` call.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /console/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /console/);
|
||||
```
|
||||
|
||||
You should call `.push()` on your `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.push\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.push\(/);
|
||||
```
|
||||
|
||||
You should push `i` to your `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.push\(\s*i\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.push\(\s*i\s*\)/);
|
||||
```
|
||||
|
||||
Your `.push()` should happen in your `for` loop.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;\s*i\s*=\s*i\s*\+\s*1\s*\)\s*\{\s*rows\.push\(\s*i\s*\);?\s*\}/)
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;\s*i\s*=\s*i\s*\+\s*1\s*\)\s*\{\s*rows\.push\(\s*i\s*\);?\s*\}/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@ Use `let` to declare a `result` variable, and assign it an empty string. An empt
|
||||
You should declare a `result` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /result/);
|
||||
assert.match(__helpers.removeJSComments(code), /result/);
|
||||
```
|
||||
|
||||
You should use `let` to declare your `result` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s*result/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s*result/);
|
||||
```
|
||||
|
||||
Your `result` variable should be an empty string.
|
||||
|
||||
+2
-2
@@ -14,13 +14,13 @@ Add a log statement to print the value of `result`. Depending on which console y
|
||||
You should add a `console.log` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(/);
|
||||
```
|
||||
|
||||
You should log your `result` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*result\s*\);?/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*result\s*\);?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+6
-6
@@ -26,37 +26,37 @@ Create a `for...of` loop to iterate through your `rows` array, assigning each va
|
||||
You should use another `for` keyword.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/for/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/for/g), 2);
|
||||
```
|
||||
|
||||
You should declare a `row` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /\s+row\s+/);
|
||||
assert.match(__helpers.removeJSComments(code), /\s+row\s+/);
|
||||
```
|
||||
|
||||
You should use `const` to declare your `row` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+row\s+/);
|
||||
assert.match(__helpers.removeJSComments(code), /const\s+row\s+/);
|
||||
```
|
||||
|
||||
Your `for...of` loop should declare your `row` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*const\s+row\s+/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*const\s+row\s+/);
|
||||
```
|
||||
|
||||
Your `row` variable should be extracted from `rows` using the `of` keyword.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*const\s+row\s+of\s+rows\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*const\s+row\s+of\s+rows\s*\)/);
|
||||
```
|
||||
|
||||
Your `for...of` loop body should be empty.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*const\s+row\s+of\s+rows\s*\)\s*\{\s*\}/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*const\s+row\s+of\s+rows\s*\)\s*\{\s*\}/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -18,19 +18,19 @@ In your `for...of` loop, use the addition operator to concatenate the `row` valu
|
||||
You should use the concatenation operator on your `result` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /(?:result\s*\+|\+\s*result)/);
|
||||
assert.match(__helpers.removeJSComments(code), /(?:result\s*\+|\+\s*result)/);
|
||||
```
|
||||
|
||||
You should concatenate `row` to your `result` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /result\s*\+\s*row|row\s*\+\s*result/);
|
||||
assert.match(__helpers.removeJSComments(code), /result\s*\+\s*row|row\s*\+\s*result/);
|
||||
```
|
||||
|
||||
You should assign the result of your concatenation back to the `result` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /result\s*=\s*(result\s*\+\s*row|row\s*\+\s*result);?/);
|
||||
assert.match(__helpers.removeJSComments(code), /result\s*=\s*(result\s*\+\s*row|row\s*\+\s*result);?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+4
-4
@@ -22,25 +22,25 @@ Use a second addition operator to concatenate a new line between the existing `r
|
||||
You should use the `\n` escape sequence. Remember that it needs to be a string, so it is wrapped in quotes.
|
||||
|
||||
```js
|
||||
assert.match(code, /('|")\\n\1/);
|
||||
assert.match(__helpers.removeJSComments(code), /('|")\\n\1/);
|
||||
```
|
||||
|
||||
You should concatenate the `\n` escape sequence to your `result` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /result\s*\+\s*('|")\\n\1/);
|
||||
assert.match(__helpers.removeJSComments(code), /result\s*\+\s*('|")\\n\1/);
|
||||
```
|
||||
|
||||
You should concatenate your `row` variable to your `\n` escape sequence.
|
||||
|
||||
```js
|
||||
assert.match(code, /result\s*\+\s*('|")\\n\1\s*\+\s*row/);
|
||||
assert.match(__helpers.removeJSComments(code), /result\s*\+\s*('|")\\n\1\s*\+\s*row/);
|
||||
```
|
||||
|
||||
You should assign the entire concatenation back to your `result` variable. Don't forget your semi-colon.
|
||||
|
||||
```js
|
||||
assert.match(code, /result\s*=\s*result\s*\+\s*('|")\\n\1\s*\+\s*row;/);
|
||||
assert.match(__helpers.removeJSComments(code), /result\s*=\s*result\s*\+\s*('|")\\n\1\s*\+\s*row;/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@ Instead of pushing `i` to the array, push the value of your `character` variable
|
||||
You should no longer push your `i` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /rows\.push\(\s*i\s*\)/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /rows\.push\(\s*i\s*\)/);
|
||||
```
|
||||
|
||||
You should push your `character` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.push\(\s*character\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.push\(\s*character\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -23,19 +23,19 @@ Use the `.repeat()` method on your `character`, and give it `i` for the number.
|
||||
You should use the `.repeat()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /\.repeat\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /\.repeat\(/);
|
||||
```
|
||||
|
||||
You should use the `.repeat()` method on your `character` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /character\.repeat\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /character\.repeat\(/);
|
||||
```
|
||||
|
||||
You should pass `i` to your `.repeat()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /character\.repeat\(\s*i\s*\)/)
|
||||
assert.match(__helpers.removeJSComments(code), /character\.repeat\(\s*i\s*\)/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ To fix this, add `1` to the value of `i` in your `.repeat()` call. Do not assign
|
||||
You should add `1` to `i` in your `.repeat()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /character\.repeat\(\s*i\s*\+\s*1\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /character\.repeat\(\s*i\s*\+\s*1\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ Declare a `padRow` function. Do not create any parameter variables yet. The func
|
||||
You should use the `function` keyword.
|
||||
|
||||
```js
|
||||
assert.match(code, /function/);
|
||||
assert.match(__helpers.removeJSComments(code), /function/);
|
||||
```
|
||||
|
||||
You should declare a `padRow` function.
|
||||
@@ -38,13 +38,13 @@ assert.isFunction(padRow);
|
||||
Your `padRow()` function should not have any parameters.
|
||||
|
||||
```js
|
||||
assert.match(code, /padRow\s*\(\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /padRow\s*\(\s*\)/);
|
||||
```
|
||||
|
||||
Your `padRow()` function should have an empty body.
|
||||
|
||||
```js
|
||||
assert.match(code, /padRow\s*\(\s*\)\s*\{\s*\}/);
|
||||
assert.match(__helpers.removeJSComments(code), /padRow\s*\(\s*\)\s*\{\s*\}/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -22,19 +22,19 @@ function name(first, second) {
|
||||
Your `padRow` function should have a `rowNumber` parameter.
|
||||
|
||||
```js
|
||||
assert.match(code, /function\s+padRow\s*\(\s*rowNumber/);
|
||||
assert.match(__helpers.removeJSComments(code), /function\s+padRow\s*\(\s*rowNumber/);
|
||||
```
|
||||
|
||||
You should add a comma after your `rowNumber` parameter.
|
||||
|
||||
```js
|
||||
assert.match(code, /function\s+padRow\s*\(\s*rowNumber\s*,\s*/);
|
||||
assert.match(__helpers.removeJSComments(code), /function\s+padRow\s*\(\s*rowNumber\s*,\s*/);
|
||||
```
|
||||
|
||||
Your `padRow` function should have a `rowCount` parameter.
|
||||
|
||||
```js
|
||||
assert.match(code, /function\s+padRow\s*\(\s*rowNumber\s*,\s*rowCount\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /function\s+padRow\s*\(\s*rowNumber\s*,\s*rowCount\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+4
-4
@@ -24,25 +24,25 @@ Use the `return` keyword to return the value of the `character` variable, repeat
|
||||
You should use the `.repeat()` method.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/\.repeat\(/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/\.repeat\(/g), 2);
|
||||
```
|
||||
|
||||
You should use the `.repeat()` method on your `character` variable.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/character\.repeat\(/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/character\.repeat\(/g), 2);
|
||||
```
|
||||
|
||||
You should pass `rowNumber` to your `.repeat()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /character\.repeat\(\s*rowNumber\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /character\.repeat\(\s*rowNumber\s*\)/);
|
||||
```
|
||||
|
||||
You should use the `return` keyword.
|
||||
|
||||
```js
|
||||
assert.match(code, /return/);
|
||||
assert.match(__helpers.removeJSComments(code), /return/);
|
||||
```
|
||||
|
||||
You should return the result of your `.repeat()` call.
|
||||
|
||||
+3
-3
@@ -22,19 +22,19 @@ Replace the `character.repeat(i + 1)` in your `.push()` call with a function cal
|
||||
You should not use `i + 1` in your `push` call.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /repeat\(\s*i\s*\+\s*1\s*\)/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /repeat\(\s*i\s*\+\s*1\s*\)/);
|
||||
```
|
||||
|
||||
You should not use `character.repeat` in your `.push()` call.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /push\(\s*character/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /push\(\s*character/);
|
||||
```
|
||||
|
||||
You should call `padRow` in your `.push()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /push\(\s*padRow\(\s*\)\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /push\(\s*padRow\(\s*\)\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -22,19 +22,19 @@ Pass `i + 1` and `count` as the arguments to your `padRow` call. Like parameters
|
||||
You should pass `i + 1` to your `padRow()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /push\(\s*padRow\(\s*i\s*\+\s*1/);
|
||||
assert.match(__helpers.removeJSComments(code), /push\(\s*padRow\(\s*i\s*\+\s*1/);
|
||||
```
|
||||
|
||||
You should have a comma after your `i + 1` argument.
|
||||
|
||||
```js
|
||||
assert.match(code, /push\(\s*padRow\(\s*i\s*\+\s*1\s*,\s*/);
|
||||
assert.match(__helpers.removeJSComments(code), /push\(\s*padRow\(\s*i\s*\+\s*1\s*,\s*/);
|
||||
```
|
||||
|
||||
You should pass `count` as your second argument.
|
||||
|
||||
```js
|
||||
assert.match(code, /push\(\s*padRow\(\s*i\s*\+\s*1\s*,\s*count\s*\)\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /push\(\s*padRow\(\s*i\s*\+\s*1\s*,\s*count\s*\)\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -23,13 +23,13 @@ Update your iterator statement in the `for` loop to use addition assignment.
|
||||
Your `for` loop should not use `i = i + 1`;
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /i\s*=\s*i\s*\+\s*1/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /i\s*=\s*i\s*\+\s*1/);
|
||||
```
|
||||
|
||||
Your `for` loop should use addition assignment with `i`.
|
||||
|
||||
```js
|
||||
assert.match(code, /i\s*\+=\s*1/);
|
||||
assert.match(__helpers.removeJSComments(code), /i\s*\+=\s*1/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -21,13 +21,13 @@ Replace your addition assignment with the increment operator for your loop itera
|
||||
Your `for` loop should not use addition assignment with `i`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /i\s*\+=\s*1/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /i\s*\+=\s*1/);
|
||||
```
|
||||
|
||||
Your `for` loop should use the increment operator on `i`.
|
||||
|
||||
```js
|
||||
assert.match(code, /i\s*\+\+/);
|
||||
assert.match(__helpers.removeJSComments(code), /i\s*\+\+/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Update your iterator to start at `1` instead of `0`.
|
||||
Your `for` loop should initialise `i` at `1`.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s+i\s*=\s*1/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s+i\s*=\s*1/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@ Update the first argument of your `padRow` call to be `i`.
|
||||
You should not pass `i + 1` to `padRow`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /padRow\(\s*i\s*\+\s*1/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /padRow\(\s*i\s*\+\s*1/);
|
||||
```
|
||||
|
||||
You should pass `i` to `padRow`.
|
||||
|
||||
```js
|
||||
assert.match(code, /padRow\(\s*i\s*,/);
|
||||
assert.match(__helpers.removeJSComments(code), /padRow\(\s*i\s*,/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -20,13 +20,13 @@ Update your loop condition to run while `i` is less than or equal to `count`.
|
||||
Your `for` loop should not check if `i` is less than `count`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /i\s*<\s*count/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /i\s*<\s*count/);
|
||||
```
|
||||
|
||||
Your `for` loop should check if `i` is less than or equal to `count`.
|
||||
|
||||
```js
|
||||
assert.match(code, /i\s*<=\s*count/);
|
||||
assert.match(__helpers.removeJSComments(code), /i\s*<=\s*count/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -24,19 +24,19 @@ Create an `if` statement with the boolean `true` as the condition. In the body,
|
||||
You should create an `if` statement.
|
||||
|
||||
```js
|
||||
assert.match(code, /if/);
|
||||
assert.match(__helpers.removeJSComments(code), /if/);
|
||||
```
|
||||
|
||||
Your `if` statement should have `true` as the condition.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*true\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*true\s*\)/);
|
||||
```
|
||||
|
||||
Your `if` body should log `"Condition is true"`.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*true\s*\)\s*\{\s*console\.log\(\s*("|')Condition is true\1\s*\);?/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*true\s*\)\s*\{\s*console\.log\(\s*("|')Condition is true\1\s*\);?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Change the condition of your `if` statement to the boolean `false`.
|
||||
Your `if` condition should have `false` as the condition.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*false\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*false\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Try changing the condition to the string `"false"`.
|
||||
Your `if` statement should have the string `"false"` as the condition.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*('|")false\1\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*('|")false\1\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ Try changing your `if` condition to an empty string `""`, which is a falsy value
|
||||
Your `if` statement should have `""` as the condition.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*("|')\1\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*("|')\1\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+5
-5
@@ -16,25 +16,25 @@ Once you complete that, use `let` to declare a `continueLoop` variable and assig
|
||||
You should not have an `if` statement.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /if\s*\(/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /if\s*\(/);
|
||||
```
|
||||
|
||||
You should not have an `else if` statement.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /else\s+if\s*\(/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /else\s+if\s*\(/);
|
||||
```
|
||||
|
||||
You should not have an `else` statement.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /else\s*\{/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /else\s*\{/);
|
||||
```
|
||||
|
||||
You should use `let` to declare a `continueLoop` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+continueLoop/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+continueLoop/);
|
||||
```
|
||||
|
||||
Your `continueLoop` variable should have the value `false`.
|
||||
@@ -46,7 +46,7 @@ assert.isFalse(continueLoop);
|
||||
You should use `let` to declare a `done` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+done/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+done/);
|
||||
```
|
||||
|
||||
Your `done` variable should have the value `0`.
|
||||
|
||||
+2
-2
@@ -22,13 +22,13 @@ Use that syntax to declare a `while` loop with `continueLoop` as the condition.
|
||||
You should use a `while` loop.
|
||||
|
||||
```js
|
||||
assert.match(code, /while/);
|
||||
assert.match(__helpers.removeJSComments(code), /while/);
|
||||
```
|
||||
|
||||
Your `while` loop should use `continueLoop` as the condition.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ To avoid this, start by using the increment operator to increase the value of th
|
||||
Your `while` loop should increment the `done` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ Update your `done == count` condition to use the strict equality operator.
|
||||
Your `if` condition should use strict equality.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*===\s*count|count\s*===\s*done)\s*\)\s*\{/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*===\s*count|count\s*===\s*done)\s*\)\s*\{/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Inside your `if` body, assign the boolean `false` to your `continueLoop` variabl
|
||||
Your `if` body should assign `false` to your `continueLoop` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*===\s*count|count\s*===\s*done)\s*\)\s*\{\s*continueLoop\s*=\s*false;?/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*===\s*count|count\s*===\s*done)\s*\)\s*\{\s*continueLoop\s*=\s*false;?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+4
-4
@@ -14,25 +14,25 @@ To make your pyramid generate again, push the result of calling `padRow` with `d
|
||||
Your loop should call the `.push()` method on your `rows`.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(/);
|
||||
```
|
||||
|
||||
You should call your `padRow` function in your `.push()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(/);
|
||||
```
|
||||
|
||||
You should pass `done` as the first argument to your `padRow` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(\s*done/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(\s*done/);
|
||||
```
|
||||
|
||||
You should pass `count` as the second argument to your `padRow` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(\s*done\s*,\s*count\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(\s*done\s*,\s*count\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Update your `while` loop condition to check if `done` is not equal to `count`.
|
||||
Your `while` loop should check if `done` and `count` are not equal.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*(?:done\s*!==\s*count|count\s*!==\s*done)/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*(?:done\s*!==\s*count|count\s*!==\s*done)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -14,13 +14,13 @@ Since you have moved the comparison into the `while` condition, you can remove y
|
||||
You should no longer have an `if` statement.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /if\s*\(\s*done\)/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /if\s*\(\s*done\)/);
|
||||
```
|
||||
|
||||
You should no longer set `continueLoop` to `false`.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/continueLoop\s*=\s*false/g), 1);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/continueLoop\s*=\s*false/g), 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Remove your `continueLoop` variable.
|
||||
You should no longer have a `continueLoop` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /continueLoop/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /continueLoop/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ Update your loop's condition to check if `done` is less than or equal to `count`
|
||||
Your `while` loop should check if `done` is less than or equal to `count`.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*done\s*<=\s*count\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*done\s*<=\s*count\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ Update your condition to check if `rows.length` is less than or equal to `count`
|
||||
Your `while` loop should check if `rows.length` is less than or equal to `count`.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*rows\.length\s*<=\s*count\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*rows\.length\s*<=\s*count\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -14,13 +14,13 @@ Now you no longer need your `done` variable. Remove the increment operation from
|
||||
You should not increment the `done` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /done\+\+/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /done\+\+/);
|
||||
```
|
||||
|
||||
You should no longer have a `done` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /done/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /done/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -23,20 +23,20 @@ assert.match(stripped, /for\s*\(/);
|
||||
Your `for` loop should initialise `i` with the value of `count`.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count/);
|
||||
```
|
||||
|
||||
Your `for` loop should use `false` as the condition.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*false/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*false/);
|
||||
```
|
||||
|
||||
|
||||
Your `for` loop should use `false` as the iteration.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*false\s*;\s*false\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*false\s*;\s*false\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Set your loop's condition to run when `i` is greater than `0`.
|
||||
Your `for` loop should run when `i` is greater than `0`.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*false\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*false\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Like you did earlier with `i = i + 1`, update your iteration statement to give `
|
||||
Your `for` loop should use `i = i - 1` as the iteration.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+4
-4
@@ -16,25 +16,25 @@ Open up the console to see the upside-down pyramid.
|
||||
Your `for` loop should call `rows.push()`.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(/);
|
||||
```
|
||||
|
||||
You should call `padRow()` in your `.push()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(/);
|
||||
```
|
||||
|
||||
You should pass `i` as the first argument to your `padRow()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i/);
|
||||
```
|
||||
|
||||
You should pass `count` as the second argument to your `padRow()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\)/);
|
||||
```
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@ Replace your iterator statement with the correct statement using the subtraction
|
||||
Your `for` loop should not use `i = i - 1`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/);
|
||||
```
|
||||
|
||||
Your `for` loop should use subtraction assignment to reduce `i` by `1`.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*-=\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*-=\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@ Replace your subtraction assignment with the decrement operator.
|
||||
Your `for` loop should not use subtraction assignment.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*-=\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*-=\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/);
|
||||
```
|
||||
|
||||
Your `for` loop should use the decrement operator.
|
||||
|
||||
```js
|
||||
assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i--\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/);
|
||||
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i--\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ To do this, you'll need to learn a couple of new array methods. Start by using `
|
||||
You should use `const` to declare a `numbers` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+numbers/);
|
||||
assert.match(__helpers.removeJSComments(code), /const\s+numbers/);
|
||||
```
|
||||
|
||||
Your `numbers` variable should be an array.
|
||||
@@ -34,7 +34,7 @@ assert.deepEqual(numbers, [1,2,3]);
|
||||
You should log your `numbers` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*numbers\s*\);?/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*numbers\s*\);?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -23,13 +23,13 @@ Use `const` to declare an `unshifted` variable, and assign it the result of call
|
||||
You should declare your `unshifted` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+unshifted/);
|
||||
assert.match(__helpers.removeJSComments(code), /const\s+unshifted/);
|
||||
```
|
||||
|
||||
You should call the `.unshift()` method on your `numbers` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /numbers\.unshift\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /numbers\.unshift\(/);
|
||||
```
|
||||
|
||||
You should pass `5` as the argument to your `.unshift()` call.
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ Directly below your `numbers` array, declare a `shifted` variable and assign it
|
||||
You should use `const` to declare a `shifted` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+shifted/);
|
||||
assert.match(__helpers.removeJSComments(code), /const\s+shifted/);
|
||||
```
|
||||
|
||||
You should call `.shift()` on your `numbers` array.
|
||||
@@ -43,7 +43,7 @@ assert.equal(shifted, 1);
|
||||
You should log your `shifted` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*shifted\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*shifted\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+4
-4
@@ -16,25 +16,25 @@ Remove your `numbers` array, and the method calls and log calls.
|
||||
You should not have a `numbers` array.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /numbers/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /numbers/);
|
||||
```
|
||||
|
||||
You should not have an `unshifted` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /unshifted/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /unshifted/);
|
||||
```
|
||||
|
||||
You should not have a `shifted` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /shifted/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /shifted/);
|
||||
```
|
||||
|
||||
You should not have your `console.log` statements.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/console\.log/g), 1);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/console\.log/g), 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -23,19 +23,19 @@ assert.match(stripped, /\.unshift/);
|
||||
You should pass a `padRow()` call as the argument for your `.unshift()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.unshift\(\s*padRow\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.unshift\(\s*padRow\(/);
|
||||
```
|
||||
|
||||
You should pass `i` as the first argument to your `padRow()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.unshift\(\s*padRow\(\s*i/)
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.unshift\(\s*padRow\(\s*i/)
|
||||
```
|
||||
|
||||
You should pass `count` as the second argument to your `padRow()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@ Start by declaring an `inverted` variable, and assigning it the value `true`. Yo
|
||||
You should declare an `inverted` variable with `let`.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+inverted/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+inverted/);
|
||||
```
|
||||
|
||||
You should initialise `inverted` with the value `true`.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+inverted\s*=\s*true;?/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+inverted\s*=\s*true;?/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -14,19 +14,19 @@ Use an `if` statement to check if `inverted` is true. Remember that you do not n
|
||||
You should use an `if` statement.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(/);
|
||||
```
|
||||
|
||||
Your `if` statement should check if `inverted` is `true`.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*inverted/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted/);
|
||||
```
|
||||
|
||||
Your `if` condition should not use any comparison operators.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*inverted\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ Now move your `.unshift()` call into your `if` block.
|
||||
Your `.unshift()` call should be in your `if` block.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -26,13 +26,13 @@ Add an `else` block to your `if` block.
|
||||
You should add an `else` block.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{/);
|
||||
```
|
||||
|
||||
Your `else` block should be empty.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*\}/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*\}/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+4
-4
@@ -14,25 +14,25 @@ When `inverted` is false, you want to build a standard pyramid. Use `.push()` li
|
||||
You should call the `.push()` method of `rows` in your `else` block.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*/);
|
||||
```
|
||||
|
||||
You should pass a `padRow()` call as the argument for your `.unshift()` method.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(/);
|
||||
```
|
||||
|
||||
You should pass `i` as the first argument to your `padRow()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(\s*i/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(\s*i/);
|
||||
```
|
||||
|
||||
You should pass `count` as the second argument to your `padRow()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(\s*i\s*,\s*count\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(\s*i\s*,\s*count\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@ Remove all comments, both single- and multi-line, from your code.
|
||||
You should not have any single-line comments in your code.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /\/\//);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /\/\//);
|
||||
```
|
||||
|
||||
You should not have any multi-line comments in your code.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /(?:\\\*|\/\*)/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /(?:\\\*|\/\*)/);
|
||||
```
|
||||
|
||||
You should not have any comments in your code.
|
||||
|
||||
+3
-3
@@ -25,19 +25,19 @@ Use camel case to declare a new `secondCharacter` variable.
|
||||
You should declare a `secondCharacter` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /secondCharacter/);
|
||||
assert.match(__helpers.removeJSComments(code), /secondCharacter/);
|
||||
```
|
||||
|
||||
You should use `let` to declare your `secondCharacter` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+secondCharacter/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+secondCharacter/);
|
||||
```
|
||||
|
||||
You should not assign a value to your `secondCharacter` variable. Do not forget your semi-colon.
|
||||
|
||||
```js
|
||||
assert.match(code, /let\s+secondCharacter;/);
|
||||
assert.match(__helpers.removeJSComments(code), /let\s+secondCharacter;/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@ Add a `console.log()` to see what the value of your `secondCharacter` variable i
|
||||
You should add a second `console.log`.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/console\.log/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/console\.log/g), 2);
|
||||
```
|
||||
|
||||
You should log your `secondCharacter` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*secondCharacter\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*secondCharacter\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -23,13 +23,13 @@ Assign the string `"Test"` to your `secondCharacter` variable below your declara
|
||||
You should not initialize `secondCharacter`. Remember that initialization means assigning a value when you declare the variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /let\s+secondCharacter\s*=/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /let\s+secondCharacter\s*=/);
|
||||
```
|
||||
|
||||
You should use the assignment operator on `secondCharacter`.
|
||||
|
||||
```js
|
||||
assert.match(code, /secondCharacter\s*=/);
|
||||
assert.match(__helpers.removeJSComments(code), /secondCharacter\s*=/);
|
||||
```
|
||||
|
||||
You should assign the string `"Test"` to your `secondCharacter` variable.
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ assert.notEqual(secondCharacter, "Test");
|
||||
You should assign the value of the `character` variable to your `secondCharacter` variable. Don't forget your semi-colon.
|
||||
|
||||
```js
|
||||
assert.match(code, /secondCharacter\s*=\s*character;/);
|
||||
assert.match(__helpers.removeJSComments(code), /secondCharacter\s*=\s*character;/);
|
||||
```
|
||||
|
||||
Your `secondCharacter` variable should now have the value `"World"`.
|
||||
|
||||
+3
-3
@@ -28,19 +28,19 @@ You should not see anything change in your console.
|
||||
You should use the `.length` property of your `rows` array.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.length/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.length/);
|
||||
```
|
||||
|
||||
You should use `rows.length` in your bracket notation.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\[\s*rows\.length/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\[\s*rows\.length/);
|
||||
```
|
||||
|
||||
You should subtract `1` from the length in your bracket notation.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\[\s*rows\.length\s*-\s*1\s*\]/)
|
||||
assert.match(__helpers.removeJSComments(code), /rows\[\s*rows\.length\s*-\s*1\s*\]/)
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -16,13 +16,13 @@ Add an `if` statement to your loop. The statement should check if `done` is equa
|
||||
You should use an `if` statement in your loop.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if/);
|
||||
```
|
||||
|
||||
Your `if` statement should use the equality operator to compare `done` and `count` in the condition.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*==\s*count|count\s*==\s*done)\s*\)\s*\{/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*==\s*count|count\s*==\s*done)\s*\)\s*\{/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ Call your `padRow` function.
|
||||
You should call the `padRow` function.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/padRow\(\)/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/padRow\(\)/g), 2);
|
||||
```
|
||||
|
||||
Your `padRow` function body should be empty.
|
||||
|
||||
+3
-3
@@ -16,19 +16,19 @@ To see the result of calling your `padRow` function, declare a `call` variable a
|
||||
You should declare a `call` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /(const|let)\s+call/);
|
||||
assert.match(__helpers.removeJSComments(code), /(const|let)\s+call/);
|
||||
```
|
||||
|
||||
You should use `const` to declare your `call` variable.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+call/);
|
||||
assert.match(__helpers.removeJSComments(code), /const\s+call/);
|
||||
```
|
||||
|
||||
You should assign `call` the result of your `padRow` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+call\s*=\s*padRow\(\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /const\s+call\s*=\s*padRow\(\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -14,13 +14,13 @@ Now add a log statement to print the value of your `call` variable.
|
||||
You should add a `console.log` call.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/console\.log/g), 2)
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/console\.log/g), 2)
|
||||
```
|
||||
|
||||
You should log your `call` variable. Don't forget the semi-colon.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*call\s*\);/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*call\s*\);/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ Pass your own name as the argument for the `name` parameter in your `padRow` cal
|
||||
You should pass a string to your `padRow()` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /padRow\(\s*("|').+\1\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /padRow\(\s*("|').+\1\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -23,13 +23,13 @@ assert.notMatch(padRow.toString(), /name/);
|
||||
You should not pass `"CamperChan"` to your `padRow` call.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /CamperChan/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /CamperChan/);
|
||||
```
|
||||
|
||||
You should still call your `padRow` function.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/padRow\(\)/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/padRow\(\)/g), 2);
|
||||
```
|
||||
|
||||
You should not have a `console.log` before your `return` keyword.
|
||||
|
||||
+2
-2
@@ -14,13 +14,13 @@ As expected, your function now returns `undefined` again. Your `call` variable i
|
||||
You should not have a `call` declaration.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /const\s*call/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /const\s*call/);
|
||||
```
|
||||
|
||||
You should not log your `call` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /call/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /call/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -20,13 +20,13 @@ You'll need to change the `while` condition to use the less than operator, inste
|
||||
You should pass `rows.length + 1` as the first argument to your `padRow` call.
|
||||
|
||||
```js
|
||||
assert.match(code, /rows\.push\(padRow\s*\(\s*rows\.length\s*\+\s*1/);
|
||||
assert.match(__helpers.removeJSComments(code), /rows\.push\(padRow\s*\(\s*rows\.length\s*\+\s*1/);
|
||||
```
|
||||
|
||||
Your `while` loop should run while `rows.length` is less than `count`.
|
||||
|
||||
```js
|
||||
assert.match(code, /while\s*\(\s*rows\.length\s*<\s*count\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /while\s*\(\s*rows\.length\s*<\s*count\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -34,19 +34,19 @@ Check the console to see the results.
|
||||
You should have an `else if` statement.
|
||||
|
||||
```js
|
||||
assert.match(code, /else\s+if\s*\(/);
|
||||
assert.match(__helpers.removeJSComments(code), /else\s+if\s*\(/);
|
||||
```
|
||||
|
||||
Your `else if` statement should check if `5` is less than `10`.
|
||||
|
||||
```js
|
||||
assert.match(code, /else\s+if\s*\(\s*5\s*<\s*10\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /else\s+if\s*\(\s*5\s*<\s*10\s*\)/);
|
||||
```
|
||||
|
||||
You should log the string `"5 is less than 10"` to the console.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*('|"|`)5\s+is\s+less\s+than\s+10\1\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*('|"|`)5\s+is\s+less\s+than\s+10\1\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -34,13 +34,13 @@ To see the results in the console, you can manually change the `<` in the `else
|
||||
You should have an `else` block.
|
||||
|
||||
```js
|
||||
assert.match(code, /else\s*\{/);
|
||||
assert.match(__helpers.removeJSComments(code), /else\s*\{/);
|
||||
```
|
||||
|
||||
Your `else` block should log the string `"This is the else block"` to the console.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*('|"|`)This\s+is\s+the\s+else\s+block\1\s*\)/);
|
||||
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*('|"|`)This\s+is\s+the\s+else\s+block\1\s*\)/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+4
-4
@@ -16,25 +16,25 @@ Do not remove your `character` variable.
|
||||
You should not have a `profession` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /let\s+profession/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /let\s+profession/);
|
||||
```
|
||||
|
||||
You should not have a `age` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /let\s+age/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /let\s+age/);
|
||||
```
|
||||
|
||||
You should not have a `console.log` statement for `age`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /console\.log\(\s*age\s*\);/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /console\.log\(\s*age\s*\);/);
|
||||
```
|
||||
|
||||
You should not have a `console.log` statement for `profession`.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /console\.log\(\s*profession\s*\);/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /console\.log\(\s*profession\s*\);/);
|
||||
```
|
||||
|
||||
You should still have your `character` variable.
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ assert.deepEqual(cities, ["London", "New York", "Mexico City"]);
|
||||
You should have two `console.log(cities)` statements in your code.
|
||||
|
||||
```js
|
||||
assert.lengthOf(code.match(/console\.log\(\s*cities\s*\)/g), 2);
|
||||
assert.lengthOf(__helpers.removeJSComments(code).match(/console\.log\(\s*cities\s*\)/g), 2);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ Remove all of your code from the previous step.
|
||||
You should remove all references to your `cities` variable.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /cities/);
|
||||
assert.notMatch(__helpers.removeJSComments(code), /cities/);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
Reference in New Issue
Block a user