mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat: only remove comments when specified in the test (#54372)
This commit is contained in:
committed by
GitHub
parent
f8426e617e
commit
adfb87e898
@@ -206,7 +206,6 @@ export type ChallengeNode = {
|
||||
msTrophyId: string;
|
||||
notes: string;
|
||||
prerequisites: PrerequisiteChallenge[];
|
||||
removeComments: boolean;
|
||||
isLocked: boolean;
|
||||
isPrivate: boolean;
|
||||
order: number;
|
||||
@@ -390,7 +389,6 @@ export type ChallengeMeta = {
|
||||
isFirstStep: boolean;
|
||||
nextChallengePath: string | null;
|
||||
prevChallengePath: string | null;
|
||||
removeComments: boolean;
|
||||
superBlock: SuperBlocks;
|
||||
title?: string;
|
||||
challengeType?: number;
|
||||
|
||||
@@ -188,7 +188,6 @@ function ShowClassic({
|
||||
instructions,
|
||||
fields: { tests, blockName },
|
||||
challengeType,
|
||||
removeComments,
|
||||
hasEditableBoundaries,
|
||||
superBlock,
|
||||
helpCategory,
|
||||
@@ -363,7 +362,6 @@ function ShowClassic({
|
||||
updateChallengeMeta({
|
||||
...challengeMeta,
|
||||
title,
|
||||
removeComments: removeComments !== false,
|
||||
challengeType,
|
||||
helpCategory
|
||||
});
|
||||
@@ -537,7 +535,6 @@ export const query = graphql`
|
||||
hasEditableBoundaries
|
||||
instructions
|
||||
notes
|
||||
removeComments
|
||||
challengeType
|
||||
helpCategory
|
||||
videoUrl
|
||||
|
||||
@@ -127,7 +127,7 @@ export function* executeChallengeSaga({ payload }) {
|
||||
const testRunner = yield call(
|
||||
getTestRunner,
|
||||
buildData,
|
||||
{ proxyLogger, removeComments: challengeMeta.removeComments },
|
||||
{ proxyLogger },
|
||||
document
|
||||
);
|
||||
const testResults = yield executeTests(testRunner, tests);
|
||||
@@ -290,8 +290,7 @@ export function* previewChallengeSaga(action) {
|
||||
}
|
||||
} else if (isJavaScriptChallenge(challengeData)) {
|
||||
const runUserCode = getTestRunner(buildData, {
|
||||
proxyLogger,
|
||||
removeComments: challengeMeta.removeComments
|
||||
proxyLogger
|
||||
});
|
||||
// without a testString the testRunner just evaluates the user's code
|
||||
yield call(runUserCode, null, previewTimeout);
|
||||
|
||||
@@ -172,29 +172,29 @@ export function getTestRunner(
|
||||
|
||||
function getJSTestRunner(
|
||||
{ build, sources }: BuildChallengeData,
|
||||
{ proxyLogger, removeComments }: TestRunnerConfig
|
||||
{ proxyLogger }: TestRunnerConfig
|
||||
) {
|
||||
return getWorkerTestRunner(
|
||||
{ build, sources },
|
||||
{ proxyLogger, removeComments },
|
||||
{ proxyLogger },
|
||||
jsWorkerExecutor
|
||||
);
|
||||
}
|
||||
|
||||
function getPyTestRunner(
|
||||
{ build, sources }: BuildChallengeData,
|
||||
{ proxyLogger, removeComments }: TestRunnerConfig
|
||||
{ proxyLogger }: TestRunnerConfig
|
||||
) {
|
||||
return getWorkerTestRunner(
|
||||
{ build, sources },
|
||||
{ proxyLogger, removeComments },
|
||||
{ proxyLogger },
|
||||
pythonWorkerExecutor
|
||||
);
|
||||
}
|
||||
|
||||
function getWorkerTestRunner(
|
||||
{ build, sources }: Pick<BuildChallengeData, 'build' | 'sources'>,
|
||||
{ proxyLogger, removeComments }: TestRunnerConfig,
|
||||
{ proxyLogger }: TestRunnerConfig,
|
||||
workerExecutor: WorkerExecutor
|
||||
) {
|
||||
const code = {
|
||||
@@ -210,7 +210,7 @@ function getWorkerTestRunner(
|
||||
|
||||
return (testString: string, testTimeout: number, firstTest = true) => {
|
||||
const result = workerExecutor.execute(
|
||||
{ build, testString, code, sources, firstTest, removeComments },
|
||||
{ build, testString, code, sources, firstTest },
|
||||
testTimeout
|
||||
) as TestWorkerExecutor;
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ export interface Context {
|
||||
|
||||
export interface TestRunnerConfig {
|
||||
proxyLogger: ProxyLogger;
|
||||
removeComments?: boolean;
|
||||
}
|
||||
|
||||
export type ProxyLogger = (msg: string) => void;
|
||||
|
||||
@@ -52,7 +52,6 @@ const defaultProps = {
|
||||
},
|
||||
notes: 'mockNotes',
|
||||
prerequisites: [] as PrerequisiteChallenge[],
|
||||
removeComments: false,
|
||||
isLocked: false,
|
||||
isPrivate: false,
|
||||
order: 1,
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ assert(confirmEnding('Abstraction', 'action') === true);
|
||||
Your code should not use the built-in method `.endsWith()` to solve the challenge.
|
||||
|
||||
```js
|
||||
assert(!/\.endsWith\(.*?\)\s*?;?/.test(code) && !/\['endsWith'\]/.test(code));
|
||||
assert(!/\.endsWith\(.*?\)\s*?;?/.test(__helpers.removeJSComments(code)) && !/\['endsWith'\]/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ assert(repeatStringNumTimes('abc', -2) === '');
|
||||
The built-in `repeat()` method should not be used.
|
||||
|
||||
```js
|
||||
assert(!/\.repeat/g.test(code));
|
||||
assert(!/\.repeat/g.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
`repeatStringNumTimes("abc", 0)` should return `""`.
|
||||
|
||||
+3
-3
@@ -53,19 +53,19 @@ assert.deepEqual(
|
||||
The `htmlColorNames` function should utilize the `splice()` method
|
||||
|
||||
```js
|
||||
assert(/.splice/.test(code));
|
||||
assert(/.splice/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should not use `shift()` or `unshift()`.
|
||||
|
||||
```js
|
||||
assert(!/shift|unshift/.test(code));
|
||||
assert(!/shift|unshift/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
You should not use array bracket notation.
|
||||
|
||||
```js
|
||||
assert(!/\[\d\]\s*=/.test(code));
|
||||
assert(!/\[\d\]\s*=/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -85,8 +85,8 @@ The definition of the `foods` object should not be changed.
|
||||
|
||||
```js
|
||||
assert(
|
||||
code.search(/let foods/) === -1 &&
|
||||
code.search(/const\s+foods\s*=\s*{\s*apples:\s*25,\s*oranges:\s*32,\s*plums:\s*28\s*};/
|
||||
__helpers.removeJSComments(code).search(/let foods/) === -1 &&
|
||||
__helpers.removeJSComments(code).search(/const\s+foods\s*=\s*{\s*apples:\s*25,\s*oranges:\s*32,\s*plums:\s*28\s*};/
|
||||
) !== -1
|
||||
);
|
||||
```
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ The `users` object should not be accessed directly
|
||||
|
||||
```js
|
||||
|
||||
assert(code.match(/users/gm).length <= 2)
|
||||
assert(__helpers.removeJSComments(code).match(/users/gm).length <= 2)
|
||||
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ assert.deepEqual(copyMachine(['it works'], 3), [
|
||||
The `copyMachine` function should utilize the `spread operator` with array `arr`
|
||||
|
||||
```js
|
||||
assert(code.match(/\.\.\.\s*arr/));
|
||||
assert(__helpers.removeJSComments(__helpers.removeJSComments(code)).match(/\.\.\.\s*arr/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ assert.deepEqual(
|
||||
The `forecast` function should utilize the `slice()` method
|
||||
|
||||
```js
|
||||
assert(/\.slice\(/.test(code));
|
||||
assert(/\.slice\(/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ The function `countOnline` should use a `for in` statement to iterate through th
|
||||
|
||||
```js
|
||||
assert(
|
||||
code.match(
|
||||
__helpers.removeJSComments(code).match(
|
||||
/for\s*\(\s*(var|let|const)\s+[a-zA-Z_$]\w*\s+in\s+[a-zA-Z_$]\w*\s*\)/
|
||||
)
|
||||
);
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ assert(userActivity.data.online === 45);
|
||||
The `online` property should be set using dot or bracket notation.
|
||||
|
||||
```js
|
||||
assert.strictEqual(code.search(/online: 45/), -1);
|
||||
assert.strictEqual(__helpers.removeJSComments(code).search(/online: 45/), -1);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+3
-3
@@ -40,7 +40,7 @@ You should not change the original line of `const arr = [2, 4, 5, 1, 7, 5, 2, 1]
|
||||
|
||||
```js
|
||||
assert(
|
||||
__helpers.removeWhiteSpace(code).match(/constarr=\[2,4,5,1,7,5,2,1\];?/)
|
||||
__helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/constarr=\[2,4,5,1,7,5,2,1\];?/)
|
||||
);
|
||||
```
|
||||
|
||||
@@ -56,14 +56,14 @@ assert.strictEqual(
|
||||
Your code should utilize the `splice()` method on `arr`.
|
||||
|
||||
```js
|
||||
assert(__helpers.removeWhiteSpace(code).match(/arr\.splice\(/));
|
||||
assert(__helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/arr\.splice\(/));
|
||||
```
|
||||
|
||||
The splice should only remove elements from `arr` and not add any additional elements to `arr`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
!__helpers.removeWhiteSpace(code).match(/arr\.splice\(\d+,\d+,\d+.*\)/g)
|
||||
!__helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/arr\.splice\(\d+,\d+,\d+.*\)/g)
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+3
-3
@@ -39,9 +39,9 @@ The `oranges`, `plums`, and `strawberries` keys should be removed using `delete`
|
||||
|
||||
```js
|
||||
assert(
|
||||
code.search(/oranges:/) !== -1 &&
|
||||
code.search(/plums:/) !== -1 &&
|
||||
code.search(/strawberries:/) !== -1
|
||||
__helpers.removeJSComments(code).search(/oranges:/) !== -1 &&
|
||||
__helpers.removeJSComments(code).search(/plums:/) !== -1 &&
|
||||
__helpers.removeJSComments(code).search(/strawberries:/) !== -1
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+3
-3
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ assert(sum === 20);
|
||||
You should use the `+` operator.
|
||||
|
||||
```js
|
||||
assert(/\+/.test(code));
|
||||
assert(/\+/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+2
-2
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+2
-2
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+3
-3
@@ -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`
|
||||
|
||||
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ assert(testNotEqual('bob') === 'Not Equal');
|
||||
You should use the `!=` operator
|
||||
|
||||
```js
|
||||
assert(code.match(/(?!!==)!=/));
|
||||
assert(__helpers.removeJSComments(code).match(/(?!!==)!=/));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+2
-2
@@ -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`
|
||||
|
||||
+2
-2
@@ -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`
|
||||
|
||||
+4
-4
@@ -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))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+4
-4
@@ -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))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+4
-4
@@ -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))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+2
-2
@@ -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))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+3
-3
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+2
-2
@@ -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]`.
|
||||
|
||||
+1
-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--
|
||||
|
||||
+4
-4
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+2
-2
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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".`
|
||||
|
||||
+3
-3
@@ -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--
|
||||
|
||||
+2
-2
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+4
-4
@@ -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--
|
||||
|
||||
+4
-4
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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`
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+3
-3
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+3
-3
@@ -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*\}/
|
||||
)
|
||||
);
|
||||
|
||||
+3
-3
@@ -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--
|
||||
|
||||
+1
-1
@@ -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]`.
|
||||
|
||||
+3
-3
@@ -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--
|
||||
|
||||
+1
-1
@@ -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]`.
|
||||
|
||||
+1
-1
@@ -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]`.
|
||||
|
||||
+1
-1
@@ -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]`.
|
||||
|
||||
+1
-1
@@ -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))
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
+1
-1
@@ -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]`.
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+2
-2
@@ -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--
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ assert(product === 5.0);
|
||||
You should use the `*` operator
|
||||
|
||||
```js
|
||||
assert(/\*/.test(code));
|
||||
assert(/\*/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ assert(product === 80);
|
||||
You should use the `*` operator.
|
||||
|
||||
```js
|
||||
assert(/\*/.test(code));
|
||||
assert(/\*/.test(__helpers.removeJSComments(code)));
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
+1
-1
@@ -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, '')
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+2
-2
@@ -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--
|
||||
|
||||
+1
-1
@@ -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)
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+3
-3
@@ -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`
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+2
-2
@@ -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--
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+3
-3
@@ -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--
|
||||
|
||||
+3
-3
@@ -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))
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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--
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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)
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -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)
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -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`
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user