mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-12 01:00:13 -04:00
feat: only remove comments when specified in the test (#54372)
This commit is contained in:
committed by
GitHub
parent
f8426e617e
commit
adfb87e898
@@ -54,7 +54,7 @@ The data in variable `myArray` should be accessed using bracket notation.
|
||||
```js
|
||||
assert(
|
||||
(function () {
|
||||
if (code.match(/\s*=\s*myArray\[0\]/g)) {
|
||||
if (__helpers.removeJSComments(code).match(/\s*=\s*myArray\[0\]/g)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -46,7 +46,7 @@ assert(myData === 8);
|
||||
You should be using bracket notation to read the correct value from `myArray`.
|
||||
|
||||
```js
|
||||
assert(/myData=myArray\[2\]\[1\]/.test(__helpers.removeWhiteSpace(code)));
|
||||
assert(/myData=myArray\[2\]\[1\]/.test(__helpers.removeWhiteSpace(__helpers.removeJSComments(code))));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -54,7 +54,7 @@ assert(secondTree === 'pine');
|
||||
Your code should use dot and bracket notation to access `myPlants`.
|
||||
|
||||
```js
|
||||
assert(/=\s*myPlants\[1\].list\[1\]/.test(code));
|
||||
assert(/=\s*myPlants\[1\].list\[1\]/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -64,7 +64,7 @@ assert(drinkValue === 'water');
|
||||
You should use bracket notation twice
|
||||
|
||||
```js
|
||||
assert(code.match(/testObj\s*?\[('|")[^'"]+\1\]/g).length > 1);
|
||||
assert(__helpers.removeJSComments(code).match(/testObj\s*?\[('|")[^'"]+\1\]/g).length > 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -60,7 +60,7 @@ assert(shirtValue === 'jersey');
|
||||
You should use dot notation twice
|
||||
|
||||
```js
|
||||
assert(code.match(/testObj\.\w+/g).length > 1);
|
||||
assert(__helpers.removeJSComments(code).match(/testObj\.\w+/g).length > 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -56,19 +56,19 @@ assert(player === 'Montana');
|
||||
You should use bracket notation to access `testObj`
|
||||
|
||||
```js
|
||||
assert(/testObj\s*?\[.*?\]/.test(code));
|
||||
assert(/testObj\s*?\[.*?\]/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should not assign the value `Montana` to the variable `player` directly.
|
||||
|
||||
```js
|
||||
assert(!code.match(/player\s*=\s*"|\'\s*Montana\s*"|\'\s*;/gi));
|
||||
assert(!__helpers.removeJSComments(code).match(/player\s*=\s*"|\'\s*Montana\s*"|\'\s*;/gi));
|
||||
```
|
||||
|
||||
You should be using the variable `playerNumber` in your bracket notation
|
||||
|
||||
```js
|
||||
assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code));
|
||||
assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -53,7 +53,7 @@ assert(myDog.bark !== undefined);
|
||||
You should not add `bark` to the initialization of `myDog`.
|
||||
|
||||
```js
|
||||
assert(!/bark[^\n]:/.test(code));
|
||||
assert(!/bark[^\n]:/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -38,7 +38,7 @@ assert(sum === 20);
|
||||
You should use the `+` operator.
|
||||
|
||||
```js
|
||||
assert(/\+/.test(code));
|
||||
assert(/\+/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -71,7 +71,7 @@ assert(switchOfStuff(4) === 'stuff');
|
||||
You should not use any `if` or `else` statements
|
||||
|
||||
```js
|
||||
assert(!/else/g.test(code) || !/if/g.test(code));
|
||||
assert(!/else/g.test(__helpers.removeJSComments(code)) || !/if/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should use a `default` statement
|
||||
@@ -83,7 +83,7 @@ assert(switchOfStuff('string-to-trigger-default-case') === 'stuff');
|
||||
You should have at least 3 `break` statements
|
||||
|
||||
```js
|
||||
assert(code.match(/break/g).length > 2);
|
||||
assert(__helpers.removeJSComments(code).match(/break/g).length > 2);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -36,7 +36,7 @@ assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);
|
||||
You should append `someAdjective` to `myStr` using the `+=` operator.
|
||||
|
||||
```js
|
||||
assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
|
||||
assert(__helpers.removeJSComments(code).match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -29,7 +29,7 @@ Assign the contents of `a` to variable `b`.
|
||||
You should not change code above the specified comment.
|
||||
|
||||
```js
|
||||
assert(/var a;/.test(code) && /a = 7;/.test(code) && /var b;/.test(code));
|
||||
assert(/var a;/.test(__helpers.removeJSComments(code)) && /a = 7;/.test(__helpers.removeJSComments(code)) && /var b;/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`b` should have a value of `7`.
|
||||
@@ -41,7 +41,7 @@ assert(typeof b === 'number' && b === 7);
|
||||
`a` should be assigned to `b` with `=`.
|
||||
|
||||
```js
|
||||
assert(/b\s*=\s*a\s*/g.test(code));
|
||||
assert(/b\s*=\s*a\s*/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -34,7 +34,7 @@ assert(processed === 2);
|
||||
You should assign `processArg` to `processed`
|
||||
|
||||
```js
|
||||
assert(/processed\s*=\s*processArg\(\s*7\s*\)/.test(code));
|
||||
assert(/processed\s*=\s*processArg\(\s*7\s*\)/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -39,19 +39,19 @@ Write chained `if`/`else if` statements to fulfill the following conditions:
|
||||
You should have at least four `else` statements
|
||||
|
||||
```js
|
||||
assert(code.match(/else/g).length > 3);
|
||||
assert(__helpers.removeJSComments(code).match(/else/g).length > 3);
|
||||
```
|
||||
|
||||
You should have at least four `if` statements
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length > 3);
|
||||
assert(__helpers.removeJSComments(code).match(/if/g).length > 3);
|
||||
```
|
||||
|
||||
You should have at least one `return` statement
|
||||
|
||||
```js
|
||||
assert(code.match(/return/g).length >= 1);
|
||||
assert(__helpers.removeJSComments(code).match(/return/g).length >= 1);
|
||||
```
|
||||
|
||||
`testSize(0)` should return the string `Tiny`
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
id: bd7123c9c441eddfaeb4bdef
|
||||
title: Comment Your JavaScript Code
|
||||
challengeType: 1
|
||||
removeComments: false
|
||||
videoUrl: 'https://scrimba.com/c/c7ynnTp'
|
||||
forumTopicId: 16783
|
||||
dashedName: comment-your-javascript-code
|
||||
|
||||
@@ -58,7 +58,7 @@ assert(testEqual('12') === 'Equal');
|
||||
You should use the `==` operator
|
||||
|
||||
```js
|
||||
assert(code.match(/==/g) && !code.match(/===/g));
|
||||
assert(__helpers.removeJSComments(code).match(/==/g) && !__helpers.removeJSComments(code).match(/===/g));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -73,7 +73,7 @@ assert(testGreaterThan(150) === 'Over 100');
|
||||
You should use the `>` operator at least twice
|
||||
|
||||
```js
|
||||
assert(code.match(/val\s*>\s*('|")*\d+('|")*/g).length > 1);
|
||||
assert(__helpers.removeJSComments(code).match(/val\s*>\s*('|")*\d+('|")*/g).length > 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -73,7 +73,7 @@ assert(testGreaterOrEqual(21) === '20 or Over');
|
||||
You should use the `>=` operator at least twice
|
||||
|
||||
```js
|
||||
assert(code.match(/val\s*>=\s*('|")*\d+('|")*/g).length > 1);
|
||||
assert(__helpers.removeJSComments(code).match(/val\s*>=\s*('|")*\d+('|")*/g).length > 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -60,7 +60,7 @@ assert(testNotEqual('bob') === 'Not Equal');
|
||||
You should use the `!=` operator
|
||||
|
||||
```js
|
||||
assert(code.match(/(?!!==)!=/));
|
||||
assert(__helpers.removeJSComments(code).match(/(?!!==)!=/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -66,7 +66,7 @@ assert(testLessThan(99) === '55 or Over');
|
||||
You should use the `<` operator at least twice
|
||||
|
||||
```js
|
||||
assert(code.match(/val\s*<\s*('|")*\d+('|")*/g).length > 1);
|
||||
assert(__helpers.removeJSComments(code).match(/val\s*<\s*('|")*\d+('|")*/g).length > 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -72,7 +72,7 @@ assert(testLessOrEqual(55) === 'More Than 24');
|
||||
You should use the `<=` operator at least twice
|
||||
|
||||
```js
|
||||
assert(code.match(/val\s*<=\s*('|")*\d+('|")*/g).length > 1);
|
||||
assert(__helpers.removeJSComments(code).match(/val\s*<=\s*('|")*\d+('|")*/g).length > 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -49,7 +49,7 @@ assert(testStrict('7') === 'Not Equal');
|
||||
You should use the `===` operator
|
||||
|
||||
```js
|
||||
assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0);
|
||||
assert(__helpers.removeJSComments(code).match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -52,7 +52,7 @@ assert(testStrictNotEqual('bob') === 'Not Equal');
|
||||
You should use the `!==` operator
|
||||
|
||||
```js
|
||||
assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0);
|
||||
assert(__helpers.removeJSComments(code).match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -40,13 +40,13 @@ Replace the two if statements with one statement, using the `&&` operator, which
|
||||
You should use the `&&` operator once
|
||||
|
||||
```js
|
||||
assert(code.match(/&&/g).length === 1);
|
||||
assert(__helpers.removeJSComments(code).match(/&&/g).length === 1);
|
||||
```
|
||||
|
||||
You should only have one `if` statement
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length === 1);
|
||||
assert(__helpers.removeJSComments(code).match(/if/g).length === 1);
|
||||
```
|
||||
|
||||
`testLogicalAnd(0)` should return the string `No`
|
||||
|
||||
@@ -43,13 +43,13 @@ Combine the two `if` statements into one statement which returns the string `Out
|
||||
You should use the `||` operator once
|
||||
|
||||
```js
|
||||
assert(code.match(/\|\|/g).length === 1);
|
||||
assert(__helpers.removeJSComments(code).match(/\|\|/g).length === 1);
|
||||
```
|
||||
|
||||
You should only have one `if` statement
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length === 1);
|
||||
assert(__helpers.removeJSComments(code).match(/if/g).length === 1);
|
||||
```
|
||||
|
||||
`testLogicalOr(0)` should return the string `Outside`
|
||||
|
||||
@@ -54,16 +54,16 @@ assert(c === 19);
|
||||
You should use the `+=` operator for each variable.
|
||||
|
||||
```js
|
||||
assert(code.match(/\+=/g).length === 3);
|
||||
assert(__helpers.removeJSComments(code).match(/\+=/g).length === 3);
|
||||
```
|
||||
|
||||
You should not modify the code above the specified comment.
|
||||
|
||||
```js
|
||||
assert(
|
||||
/let a = 3;/.test(code) &&
|
||||
/let b = 17;/.test(code) &&
|
||||
/let c = 12;/.test(code)
|
||||
/let a = 3;/.test(__helpers.removeJSComments(code)) &&
|
||||
/let b = 17;/.test(__helpers.removeJSComments(code)) &&
|
||||
/let c = 12;/.test(__helpers.removeJSComments(code))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -48,16 +48,16 @@ assert(c === 3);
|
||||
You should use the `/=` operator for each variable.
|
||||
|
||||
```js
|
||||
assert(code.match(/\/=/g).length === 3);
|
||||
assert(__helpers.removeJSComments(code).match(/\/=/g).length === 3);
|
||||
```
|
||||
|
||||
You should not modify the code above the specified comment.
|
||||
|
||||
```js
|
||||
assert(
|
||||
/let a = 48;/.test(code) &&
|
||||
/let b = 108;/.test(code) &&
|
||||
/let c = 33;/.test(code)
|
||||
/let a = 48;/.test(__helpers.removeJSComments(code)) &&
|
||||
/let b = 108;/.test(__helpers.removeJSComments(code)) &&
|
||||
/let c = 33;/.test(__helpers.removeJSComments(code))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -48,16 +48,16 @@ assert(c === 46);
|
||||
You should use the `*=` operator for each variable.
|
||||
|
||||
```js
|
||||
assert(code.match(/\*=/g).length === 3);
|
||||
assert(__helpers.removeJSComments(code).match(/\*=/g).length === 3);
|
||||
```
|
||||
|
||||
You should not modify the code above the specified comment.
|
||||
|
||||
```js
|
||||
assert(
|
||||
/let a = 5;/.test(code) &&
|
||||
/let b = 12;/.test(code) &&
|
||||
/let c = 4\.6;/.test(code)
|
||||
/let a = 5;/.test(__helpers.removeJSComments(code)) &&
|
||||
/let b = 12;/.test(__helpers.removeJSComments(code)) &&
|
||||
/let c = 4\.6;/.test(__helpers.removeJSComments(code))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -48,14 +48,14 @@ assert(c === 2);
|
||||
You should use the `-=` operator for each variable.
|
||||
|
||||
```js
|
||||
assert(code.match(/-=/g).length === 3);
|
||||
assert(__helpers.removeJSComments(code).match(/-=/g).length === 3);
|
||||
```
|
||||
|
||||
You should not modify the code above the specified comment.
|
||||
|
||||
```js
|
||||
assert(
|
||||
/let a = 11;/.test(code) && /let b = 9;/.test(code) && /let c = 3;/.test(code)
|
||||
/let a = 11;/.test(__helpers.removeJSComments(code)) && /let b = 9;/.test(__helpers.removeJSComments(code)) && /let c = 3;/.test(__helpers.removeJSComments(code))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -47,19 +47,19 @@ assert(myStr === 'This is the start. This is the end.');
|
||||
You should use the `+` operator to build `myStr`.
|
||||
|
||||
```js
|
||||
assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));
|
||||
assert(__helpers.removeJSComments(code).match(/(["']).*\1\s*\+\s*(["']).*\2/g));
|
||||
```
|
||||
|
||||
`myStr` should be created using the `const` keyword.
|
||||
|
||||
```js
|
||||
assert(/const\s+myStr/.test(code));
|
||||
assert(/const\s+myStr/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should assign the result to the `myStr` variable.
|
||||
|
||||
```js
|
||||
assert(/myStr\s*=/.test(code));
|
||||
assert(/myStr\s*=/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -43,7 +43,7 @@ assert(myStr === 'This is the first sentence. This is the second sentence.');
|
||||
You should use the `+=` operator to build `myStr`.
|
||||
|
||||
```js
|
||||
assert(code.match(/myStr\s*\+=\s*(["']).*\1/g));
|
||||
assert(__helpers.removeJSComments(code).match(/myStr\s*\+=\s*(["']).*\1/g));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -35,7 +35,7 @@ assert(typeof myName !== 'undefined' && myName.length > 2);
|
||||
You should use two `+` operators to build `myStr` with `myName` inside it.
|
||||
|
||||
```js
|
||||
assert(code.match(/["']\s*\+\s*myName\s*\+\s*["']/g).length > 0);
|
||||
assert(__helpers.removeJSComments(code).match(/["']\s*\+\s*myName\s*\+\s*["']/g).length > 0);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -34,13 +34,13 @@ Push the odd numbers from 9 through 1 to `myArray` using a `for` loop.
|
||||
You should be using a `for` loop for this.
|
||||
|
||||
```js
|
||||
assert(/for\s*\([^)]+?\)/.test(code));
|
||||
assert(/for\s*\([^)]+?\)/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should be using the array method `push`.
|
||||
|
||||
```js
|
||||
assert(code.match(/myArray.push/));
|
||||
assert(__helpers.removeJSComments(code).match(/myArray.push/));
|
||||
```
|
||||
|
||||
`myArray` should equal `[9, 7, 5, 3, 1]`.
|
||||
|
||||
@@ -37,7 +37,7 @@ Look at the `ourName` example above if you get stuck.
|
||||
You should declare `myName` with the `var` keyword, ending with a semicolon
|
||||
|
||||
```js
|
||||
assert(/var\s+myName\s*;/.test(code));
|
||||
assert(/var\s+myName\s*;/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -38,25 +38,25 @@ assert(myVar === 10);
|
||||
`myVar = myVar - 1;` should be changed.
|
||||
|
||||
```js
|
||||
assert(!code.match(/myVar\s*=\s*myVar\s*[-]\s*1.*?;?/));
|
||||
assert(!__helpers.removeJSComments(code).match(/myVar\s*=\s*myVar\s*[-]\s*1.*?;?/));
|
||||
```
|
||||
|
||||
You should not assign `myVar` with `10`.
|
||||
|
||||
```js
|
||||
assert(!code.match(/myVar\s*=\s*10.*?;?/));
|
||||
assert(!__helpers.removeJSComments(code).match(/myVar\s*=\s*10.*?;?/));
|
||||
```
|
||||
|
||||
You should use the `--` operator on `myVar`.
|
||||
|
||||
```js
|
||||
assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code));
|
||||
assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should not change code above the specified comment.
|
||||
|
||||
```js
|
||||
assert(/let myVar = 11;/.test(code));
|
||||
assert(/let myVar = 11;/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -55,7 +55,7 @@ assert(typeof myDog === 'object' && myDog.tails === undefined);
|
||||
You should not modify the `myDog` setup.
|
||||
|
||||
```js
|
||||
assert(code.match(/"tails": 1/g).length > 0);
|
||||
assert(__helpers.removeJSComments(code).match(/"tails": 1/g).length > 0);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -26,13 +26,13 @@ assert(quotient === 2.2);
|
||||
You should use the `/` operator to divide 4.4 by 2
|
||||
|
||||
```js
|
||||
assert(/4\.40*\s*\/\s*2\.*0*/.test(code));
|
||||
assert(/4\.40*\s*\/\s*2\.*0*/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
The quotient variable should only be assigned once
|
||||
|
||||
```js
|
||||
assert(code.match(/quotient\s*=/g).length === 1);
|
||||
assert(__helpers.removeJSComments(code).match(/quotient\s*=/g).length === 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -35,7 +35,7 @@ assert(quotient === 2);
|
||||
You should use the `/` operator.
|
||||
|
||||
```js
|
||||
assert(/\d+\s*\/\s*\d+/.test(code));
|
||||
assert(/\d+\s*\/\s*\d+/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -36,7 +36,7 @@ I am a "double quoted" string inside "double quotes".
|
||||
You should use two double quotes (`"`) and four escaped double quotes (`\"`).
|
||||
|
||||
```js
|
||||
assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2);
|
||||
assert(__helpers.removeJSComments(code).match(/\\"/g).length === 4 && __helpers.removeJSComments(code).match(/[^\\]"/g).length === 2);
|
||||
```
|
||||
|
||||
Variable `myStr` should contain the string: `I am a "double quoted" string inside "double quotes".`
|
||||
|
||||
@@ -29,8 +29,8 @@ You should not change the variable declarations in the `// Setup` section.
|
||||
|
||||
```js
|
||||
assert(
|
||||
code.match(/let lastNameLength = 0;/) &&
|
||||
code.match(/const lastName = "Lovelace";/)
|
||||
__helpers.removeJSComments(code).match(/let lastNameLength = 0;/) &&
|
||||
__helpers.removeJSComments(code).match(/const lastName = "Lovelace";/)
|
||||
);
|
||||
```
|
||||
|
||||
@@ -43,7 +43,7 @@ assert(typeof lastNameLength !== 'undefined' && lastNameLength === 8);
|
||||
You should be getting the length of `lastName` by using `.length` like this: `lastName.length`.
|
||||
|
||||
```js
|
||||
assert(code.match(/=\s*lastName\.length/g) && !code.match(/lastName\s*=\s*8/));
|
||||
assert(__helpers.removeJSComments(code).match(/=\s*lastName\.length/g) && !__helpers.removeJSComments(code).match(/lastName\s*=\s*8/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -39,7 +39,7 @@ Set `remainder` equal to the remainder of `11` divided by `3` using the <dfn>rem
|
||||
The variable `remainder` should be initialized
|
||||
|
||||
```js
|
||||
assert(/(const|let|var)\s+?remainder/.test(code));
|
||||
assert(/(const|let|var)\s+?remainder/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
The value of `remainder` should be `2`
|
||||
@@ -51,7 +51,7 @@ assert(remainder === 2);
|
||||
You should use the `%` operator
|
||||
|
||||
```js
|
||||
assert(/\s+?remainder\s*?=\s*?.*%.*;?/.test(code));
|
||||
assert(/\s+?remainder\s*?=\s*?.*%.*;?/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -36,7 +36,7 @@ assert((randomFraction() + '').match(/\./g));
|
||||
You should be using `Math.random` to generate the random decimal number.
|
||||
|
||||
```js
|
||||
assert(code.match(/Math\.random/g).length >= 0);
|
||||
assert(__helpers.removeJSComments(code).match(/Math\.random/g).length >= 0);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -46,22 +46,22 @@ assert(
|
||||
You should use `Math.random` to generate a random number.
|
||||
|
||||
```js
|
||||
assert(code.match(/Math.random/g).length >= 1);
|
||||
assert(__helpers.removeJSComments(code).match(/Math.random/g).length >= 1);
|
||||
```
|
||||
|
||||
You should have multiplied the result of `Math.random` by 10 to make it a number in the range from zero to nine.
|
||||
|
||||
```js
|
||||
assert(
|
||||
code.match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) ||
|
||||
code.match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g)
|
||||
__helpers.removeJSComments(code).match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) ||
|
||||
__helpers.removeJSComments(code).match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g)
|
||||
);
|
||||
```
|
||||
|
||||
You should use `Math.floor` to remove the decimal part of the number.
|
||||
|
||||
```js
|
||||
assert(code.match(/Math.floor/g).length >= 1);
|
||||
assert(__helpers.removeJSComments(code).match(/Math.floor/g).length >= 1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -49,10 +49,10 @@ assert(randomRange(0, 1) % 1 === 0);
|
||||
assert(
|
||||
(function () {
|
||||
if (
|
||||
code.match(/myMax/g).length > 1 &&
|
||||
code.match(/myMin/g).length > 2 &&
|
||||
code.match(/Math.floor/g) &&
|
||||
code.match(/Math.random/g)
|
||||
__helpers.removeJSComments(code).match(/myMax/g).length > 1 &&
|
||||
__helpers.removeJSComments(code).match(/myMin/g).length > 2 &&
|
||||
__helpers.removeJSComments(code).match(/Math.floor/g) &&
|
||||
__helpers.removeJSComments(code).match(/Math.random/g)
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -36,7 +36,7 @@ assert(myGlobal === 10);
|
||||
`myGlobal` should be declared using the `let` or `const` keywords
|
||||
|
||||
```js
|
||||
assert(/(let|const)\s+myGlobal/.test(code));
|
||||
assert(/(let|const)\s+myGlobal/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`oopsGlobal` should be a global variable and have a value of `5`
|
||||
|
||||
@@ -45,7 +45,7 @@ assert(myOutfit() === 'sweater');
|
||||
You should not change the return statement.
|
||||
|
||||
```js
|
||||
assert(/return outerWear/.test(code));
|
||||
assert(/return outerWear/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -39,20 +39,20 @@ You should not use the assignment operator.
|
||||
|
||||
```js
|
||||
assert(
|
||||
/let\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2})/.test(code)
|
||||
/let\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2})/.test(__helpers.removeJSComments(code))
|
||||
);
|
||||
```
|
||||
|
||||
You should use the `++` operator.
|
||||
|
||||
```js
|
||||
assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code));
|
||||
assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should not change code above the specified comment.
|
||||
|
||||
```js
|
||||
assert(/let myVar = 87;/.test(code));
|
||||
assert(/let myVar = 87;/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -26,7 +26,7 @@ Define a variable `a` with `var` and initialize it to a value of `9`.
|
||||
You should initialize `a` to a value of `9`.
|
||||
|
||||
```js
|
||||
assert(/var\s+a\s*=\s*9(\s*;?\s*)$/.test(code));
|
||||
assert(/var\s+a\s*=\s*9(\s*;?\s*)$/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -30,20 +30,20 @@ Convert the logic to use `else if` statements.
|
||||
You should have at least two `else` statements
|
||||
|
||||
```js
|
||||
assert(code.match(/else/g).length > 1);
|
||||
assert(__helpers.removeJSComments(code).match(/else/g).length > 1);
|
||||
```
|
||||
|
||||
You should have at least two `if` statements
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length > 1);
|
||||
assert(__helpers.removeJSComments(code).match(/if/g).length > 1);
|
||||
```
|
||||
|
||||
You should have closing and opening curly braces for each `if else` code block.
|
||||
|
||||
```js
|
||||
assert(
|
||||
code.match(
|
||||
__helpers.removeJSComments(code).match(
|
||||
/if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s+if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s*\{[\s\S]+\s*\}/
|
||||
)
|
||||
);
|
||||
|
||||
@@ -28,13 +28,13 @@ Combine the `if` statements into a single `if/else` statement.
|
||||
You should only have one `if` statement in the editor
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length === 1);
|
||||
assert(__helpers.removeJSComments(code).match(/if/g).length === 1);
|
||||
```
|
||||
|
||||
You should use an `else` statement
|
||||
|
||||
```js
|
||||
assert(/else/g.test(code));
|
||||
assert(/else/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`testElse(4)` should return the string `5 or Smaller`
|
||||
@@ -64,7 +64,7 @@ assert(testElse(10) === 'Bigger than 5');
|
||||
You should not change the code above or below the specified comments.
|
||||
|
||||
```js
|
||||
assert(/let result = "";/.test(code) && /return result;/.test(code));
|
||||
assert(/let result = "";/.test(__helpers.removeJSComments(code)) && /return result;/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -32,7 +32,7 @@ Push the odd numbers from 1 through 9 to `myArray` using a `for` loop.
|
||||
You should be using a `for` loop for this.
|
||||
|
||||
```js
|
||||
assert(/for\s*\([^)]+?\)/.test(code));
|
||||
assert(/for\s*\([^)]+?\)/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`myArray` should equal `[1, 3, 5, 7, 9]`.
|
||||
|
||||
@@ -30,7 +30,7 @@ Declare and initialize a variable `total` to `0`. Use a `for` loop to add the va
|
||||
`total` should be declared and initialized to 0.
|
||||
|
||||
```js
|
||||
assert(code.match(/(var|let|const)\s*?total\s*=\s*0.*?;?/));
|
||||
assert(__helpers.removeJSComments(code).match(/(var|let|const)\s*?total\s*=\s*0.*?;?/));
|
||||
```
|
||||
|
||||
`total` should equal 20.
|
||||
@@ -42,13 +42,13 @@ assert(total === 20);
|
||||
You should use a `for` loop to iterate through `myArr`.
|
||||
|
||||
```js
|
||||
assert(/for\s*\(/g.test(code) && /myArr\s*\[/g.test(code));
|
||||
assert(/for\s*\(/g.test(__helpers.removeJSComments(code)) && /myArr\s*\[/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should not attempt to directly assign the value 20 to `total`.
|
||||
|
||||
```js
|
||||
assert(!__helpers.removeWhiteSpace(code).match(/total[=+-]0*[1-9]+/gm));
|
||||
assert(!__helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/total[=+-]0*[1-9]+/gm));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -56,7 +56,7 @@ Change the `while` loop in the code to a `do...while` loop so the loop will push
|
||||
You should be using a `do...while` loop for this exercise.
|
||||
|
||||
```js
|
||||
assert(code.match(/do/g));
|
||||
assert(__helpers.removeJSComments(code).match(/do/g));
|
||||
```
|
||||
|
||||
`myArray` should equal `[10]`.
|
||||
|
||||
@@ -44,7 +44,7 @@ Use a `for` loop to push the values 1 through 5 onto `myArray`.
|
||||
You should be using a `for` loop for this.
|
||||
|
||||
```js
|
||||
assert(/for\s*\([^)]+?\)/.test(code));
|
||||
assert(/for\s*\([^)]+?\)/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`myArray` should equal `[1, 2, 3, 4, 5]`.
|
||||
|
||||
@@ -36,7 +36,7 @@ Add the numbers 5 through 0 (inclusive) in descending order to `myArray` using a
|
||||
You should be using a `while` loop for this.
|
||||
|
||||
```js
|
||||
assert(code.match(/while/g));
|
||||
assert(__helpers.removeJSComments(code).match(/while/g));
|
||||
```
|
||||
|
||||
`myArray` should equal `[5, 4, 3, 2, 1, 0]`.
|
||||
|
||||
@@ -48,7 +48,7 @@ You should add a local `myVar` variable.
|
||||
```js
|
||||
assert(
|
||||
/functionmyLocalScope\(\)\{.*(var|let|const)myVar[\s\S]*}/.test(
|
||||
__helpers.removeWhiteSpace(code)
|
||||
__helpers.removeWhiteSpace(__helpers.removeJSComments(code))
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
@@ -47,7 +47,7 @@ assert(
|
||||
You should use `pop()` on `myArray`.
|
||||
|
||||
```js
|
||||
assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(code));
|
||||
assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`removedFromMyArray` should only contain `["cat", 2]`.
|
||||
|
||||
@@ -52,7 +52,7 @@ You should be using correct index to modify the value in `myArray`.
|
||||
```js
|
||||
assert(
|
||||
(function () {
|
||||
if (code.match(/myArray\[0\]\s*=\s*/g)) {
|
||||
if (__helpers.removeJSComments(code).match(/myArray\[0\]\s*=\s*/g)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -94,13 +94,13 @@ assert(sequentialSizes(9) === 'High');
|
||||
You should not use any `if` or `else` statements
|
||||
|
||||
```js
|
||||
assert(!/else/g.test(code) || !/if/g.test(code));
|
||||
assert(!/else/g.test(__helpers.removeJSComments(code)) || !/if/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should have nine `case` statements
|
||||
|
||||
```js
|
||||
assert(code.match(/case/g).length === 9);
|
||||
assert(__helpers.removeJSComments(code).match(/case/g).length === 9);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -28,7 +28,7 @@ assert(product === 5.0);
|
||||
You should use the `*` operator
|
||||
|
||||
```js
|
||||
assert(/\*/.test(code));
|
||||
assert(/\*/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -36,7 +36,7 @@ assert(product === 80);
|
||||
You should use the `*` operator.
|
||||
|
||||
```js
|
||||
assert(/\*/.test(code));
|
||||
assert(/\*/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -60,7 +60,7 @@ You should call `functionWithArgs` with two numbers after you define it.
|
||||
```js
|
||||
assert(
|
||||
/functionWithArgs\([-+]?\d*\.?\d*,[-+]?\d*\.?\d*\)/.test(
|
||||
code.replace(/\s/g, '')
|
||||
__helpers.removeJSComments(code).replace(/\s/g, '')
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
@@ -47,7 +47,7 @@ assert(compareEquality('20', 20) === 'Not Equal');
|
||||
You should use the `===` operator
|
||||
|
||||
```js
|
||||
assert(code.match(/===/g));
|
||||
assert(__helpers.removeJSComments(code).match(/===/g));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -47,7 +47,7 @@ You should remove all the backslashes (`\`).
|
||||
|
||||
```js
|
||||
assert(
|
||||
!/\\/g.test(code) &&
|
||||
!/\\/g.test(__helpers.removeJSComments(code)) &&
|
||||
myStr.match(
|
||||
'\\s*<a href\\s*=\\s*"http://www.example.com"\\s*target\\s*=\\s*"_blank">\\s*Link\\s*</a>\\s*'
|
||||
)
|
||||
@@ -57,7 +57,7 @@ assert(
|
||||
You should have two single quotes `'` and four double quotes `"`.
|
||||
|
||||
```js
|
||||
assert(code.match(/"/g).length === 4 && code.match(/'/g).length === 2);
|
||||
assert(__helpers.removeJSComments(code).match(/"/g).length === 4 && __helpers.removeJSComments(code).match(/'/g).length === 2);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -66,7 +66,7 @@ Your code should not rely on any kind of loops (`for` or `while` or higher order
|
||||
|
||||
```js
|
||||
assert(
|
||||
!code.match(/for|while|forEach|map|filter|reduce/g)
|
||||
!__helpers.removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g)
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -45,19 +45,19 @@ Change the chained `if`/`else if` statements into a `switch` statement.
|
||||
You should not use any `else` statements anywhere in the editor
|
||||
|
||||
```js
|
||||
assert(!/else/g.test(code));
|
||||
assert(!/else/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should not use any `if` statements anywhere in the editor
|
||||
|
||||
```js
|
||||
assert(!/if/g.test(code));
|
||||
assert(!/if/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should have at least four `break` statements
|
||||
|
||||
```js
|
||||
assert(code.match(/break/g).length >= 4);
|
||||
assert(__helpers.removeJSComments(code).match(/break/g).length >= 4);
|
||||
```
|
||||
|
||||
`chainToSwitch("bob")` should return the string `Marley`
|
||||
|
||||
@@ -52,7 +52,7 @@ assert(isLess(15, 10) === false);
|
||||
You should not use any `if` or `else` statements
|
||||
|
||||
```js
|
||||
assert(!/if|else/g.test(code));
|
||||
assert(!/if|else/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -63,13 +63,13 @@ assert(caseInSwitch(4) === 'delta');
|
||||
You should not use any `if` or `else` statements
|
||||
|
||||
```js
|
||||
assert(!/else/g.test(code) || !/if/g.test(code));
|
||||
assert(!/else/g.test(__helpers.removeJSComments(code)) || !/if/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should have at least 3 `break` statements
|
||||
|
||||
```js
|
||||
assert(code.match(/break/g).length > 2);
|
||||
assert(__helpers.removeJSComments(code).match(/break/g).length > 2);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -35,7 +35,7 @@ Assign the value `7` to variable `a`.
|
||||
You should not change code above the specified comment.
|
||||
|
||||
```js
|
||||
assert(/var a;/.test(code));
|
||||
assert(/var a;/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`a` should have a value of 7.
|
||||
|
||||
@@ -35,7 +35,7 @@ assert(difference === 12);
|
||||
You should only subtract one number from `45`.
|
||||
|
||||
```js
|
||||
assert(/difference=45-33;?/.test(__helpers.removeWhiteSpace(code)));
|
||||
assert(/difference=45-33;?/.test(__helpers.removeWhiteSpace(__helpers.removeJSComments(code))));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -40,7 +40,7 @@ assert(myStr === 'Hello World');
|
||||
You should not change the code above the specified comment.
|
||||
|
||||
```js
|
||||
assert(/myStr = "Jello World"/.test(code));
|
||||
assert(/myStr = "Jello World"/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -56,19 +56,19 @@ assert(typeof titleCaseOver !== 'undefined' && titleCaseOver === 9000);
|
||||
`studlyCapVar` should use camelCase in both declaration and assignment sections.
|
||||
|
||||
```js
|
||||
assert(code.match(/studlyCapVar/g).length === 2);
|
||||
assert(__helpers.removeJSComments(code).match(/studlyCapVar/g).length === 2);
|
||||
```
|
||||
|
||||
`properCamelCase` should use camelCase in both declaration and assignment sections.
|
||||
|
||||
```js
|
||||
assert(code.match(/properCamelCase/g).length === 2);
|
||||
assert(__helpers.removeJSComments(code).match(/properCamelCase/g).length === 2);
|
||||
```
|
||||
|
||||
`titleCaseOver` should use camelCase in both declaration and assignment sections.
|
||||
|
||||
```js
|
||||
assert(code.match(/titleCaseOver/g).length === 2);
|
||||
assert(__helpers.removeJSComments(code).match(/titleCaseOver/g).length === 2);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -39,9 +39,9 @@ You should not change code below the specified comment.
|
||||
|
||||
```js
|
||||
assert(
|
||||
/a = a \+ 1;/.test(code) &&
|
||||
/b = b \+ 5;/.test(code) &&
|
||||
/c = c \+ " String!";/.test(code)
|
||||
/a = a \+ 1;/.test(__helpers.removeJSComments(code)) &&
|
||||
/b = b \+ 5;/.test(__helpers.removeJSComments(code)) &&
|
||||
/c = c \+ " String!";/.test(__helpers.removeJSComments(code))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ assert(/happy coder/gi.test(myDog.name));
|
||||
You should not edit the `myDog` definition.
|
||||
|
||||
```js
|
||||
assert(/"name": "Coder"/.test(code));
|
||||
assert(/"name": "Coder"/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -41,7 +41,7 @@ assert(firstLetterOfLastName === 'L');
|
||||
You should use bracket notation.
|
||||
|
||||
```js
|
||||
assert(code.match(/firstLetterOfLastName\s*=\s*lastName\s*\[\s*\d\s*\]/));
|
||||
assert(__helpers.removeJSComments(code).match(/firstLetterOfLastName\s*=\s*lastName\s*\[\s*\d\s*\]/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -39,7 +39,7 @@ assert(lastLetterOfLastName === 'e');
|
||||
You should use `.length` to get the last letter.
|
||||
|
||||
```js
|
||||
assert(code.match(/\.length/g).length > 0);
|
||||
assert(__helpers.removeJSComments(code).match(/\.length/g).length > 0);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -39,7 +39,7 @@ assert(thirdLetterOfLastName === 'v');
|
||||
You should use bracket notation.
|
||||
|
||||
```js
|
||||
assert(code.match(/thirdLetterOfLastName\s*=\s*lastName\s*\[\s*\d\s*\]/));
|
||||
assert(__helpers.removeJSComments(code).match(/thirdLetterOfLastName\s*=\s*lastName\s*\[\s*\d\s*\]/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -39,7 +39,7 @@ assert(secondToLastLetterOfLastName === 'c');
|
||||
You should use `.length` to get the second last letter.
|
||||
|
||||
```js
|
||||
assert(code.match(/\.length/g).length > 0);
|
||||
assert(__helpers.removeJSComments(code).match(/\.length/g).length > 0);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
@@ -54,7 +54,7 @@ In the `checkSign` function, use multiple conditional operators - following the
|
||||
`checkSign` should use multiple conditional operators
|
||||
|
||||
```js
|
||||
assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?\s*?\?\s*?.+?\s*?:\s*?.+?/gi.test(code));
|
||||
assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?\s*?\?\s*?.+?\s*?:\s*?.+?/gi.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`checkSign(10)` should return the string `positive`. Note that capitalization matters
|
||||
|
||||
@@ -59,7 +59,7 @@ Your code should not rely on any kind of loops (`for`, `while` or higher order f
|
||||
|
||||
```js
|
||||
assert(
|
||||
!code.match(/for|while|forEach|map|filter|reduce/g)
|
||||
!__helpers.removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g)
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Your code should not use any loop syntax (`for` or `while` or higher order funct
|
||||
|
||||
```js
|
||||
assert(
|
||||
!code.match(/for|while|forEach|map|filter|reduce/g)
|
||||
!__helpers.removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g)
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ Use the conditional operator in the `checkEqual` function to check if two number
|
||||
`checkEqual` should use the conditional operator
|
||||
|
||||
```js
|
||||
assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?/.test(code));
|
||||
assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`checkEqual(1, 2)` should return the string `Not Equal`
|
||||
|
||||
@@ -34,7 +34,7 @@ Use `parseInt()` in the `convertToInteger` function so it converts a binary numb
|
||||
`convertToInteger` should use the `parseInt()` function
|
||||
|
||||
```js
|
||||
assert(/parseInt/g.test(code));
|
||||
assert(/parseInt/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`convertToInteger("10011")` should return a number
|
||||
|
||||
@@ -26,7 +26,7 @@ Use `parseInt()` in the `convertToInteger` function so it converts the input str
|
||||
`convertToInteger` should use the `parseInt()` function
|
||||
|
||||
```js
|
||||
assert(/parseInt/g.test(code));
|
||||
assert(/parseInt/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`convertToInteger("56")` should return a number
|
||||
|
||||
@@ -83,14 +83,14 @@ assert(typeof phoneticLookup('') === 'undefined');
|
||||
You should not modify the `return` statement
|
||||
|
||||
```js
|
||||
assert(code.match(/return\sresult;/));
|
||||
assert(__helpers.removeJSComments(code).match(/return\sresult;/));
|
||||
```
|
||||
|
||||
You should not use `case`, `switch`, or `if` statements
|
||||
|
||||
```js
|
||||
assert(
|
||||
!/case|switch|if/g.test(code.replace(/([/]{2}.*)|([/][*][^/*]*[*][/])/g, ''))
|
||||
!/case|switch|if/g.test(__helpers.removeJSComments(code).replace(/([/]{2}.*)|([/][*][^/*]*[*][/])/g, ''))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ assert(
|
||||
You should not directly use the values `dog`, `ran`, `big`, or `quickly` to create `wordBlanks`.
|
||||
|
||||
```js
|
||||
const newCode = removeAssignments(code);
|
||||
const newCode = removeAssignments(__helpers.removeJSComments(code));
|
||||
assert(
|
||||
!/dog/.test(newCode) &&
|
||||
!/ran/.test(newCode) &&
|
||||
|
||||
@@ -50,7 +50,7 @@ You should call `reusableFunction` once it is defined.
|
||||
|
||||
```js
|
||||
const functionStr = reusableFunction && __helpers.removeWhiteSpace(reusableFunction.toString());
|
||||
const codeWithoutFunction = __helpers.removeWhiteSpace(code).replace(/reusableFunction\(\)\{/g, '');
|
||||
const codeWithoutFunction = __helpers.removeWhiteSpace(__helpers.removeJSComments(code)).replace(/reusableFunction\(\)\{/g, '');
|
||||
assert(/reusableFunction\(\)/.test(codeWithoutFunction));
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user