diff --git a/client/src/redux/prop-types.ts b/client/src/redux/prop-types.ts index f2e89b9b72b..fcdabb77c9c 100644 --- a/client/src/redux/prop-types.ts +++ b/client/src/redux/prop-types.ts @@ -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; diff --git a/client/src/templates/Challenges/classic/show.tsx b/client/src/templates/Challenges/classic/show.tsx index 7f919490d30..ea818e95f56 100644 --- a/client/src/templates/Challenges/classic/show.tsx +++ b/client/src/templates/Challenges/classic/show.tsx @@ -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 diff --git a/client/src/templates/Challenges/redux/execute-challenge-saga.js b/client/src/templates/Challenges/redux/execute-challenge-saga.js index 5d1d2fa02f8..42c1c61f54e 100644 --- a/client/src/templates/Challenges/redux/execute-challenge-saga.js +++ b/client/src/templates/Challenges/redux/execute-challenge-saga.js @@ -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); diff --git a/client/src/templates/Challenges/utils/build.ts b/client/src/templates/Challenges/utils/build.ts index 2a87dbcd8f4..acc5f532338 100644 --- a/client/src/templates/Challenges/utils/build.ts +++ b/client/src/templates/Challenges/utils/build.ts @@ -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, - { 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; diff --git a/client/src/templates/Challenges/utils/frame.ts b/client/src/templates/Challenges/utils/frame.ts index 47cfbfbc196..469f0b22783 100644 --- a/client/src/templates/Challenges/utils/frame.ts +++ b/client/src/templates/Challenges/utils/frame.ts @@ -28,7 +28,6 @@ export interface Context { export interface TestRunnerConfig { proxyLogger: ProxyLogger; - removeComments?: boolean; } export type ProxyLogger = (msg: string) => void; diff --git a/client/src/templates/Introduction/components/block.test.tsx b/client/src/templates/Introduction/components/block.test.tsx index 3050cbbc551..21faa38db1d 100644 --- a/client/src/templates/Introduction/components/block.test.tsx +++ b/client/src/templates/Introduction/components/block.test.tsx @@ -52,7 +52,6 @@ const defaultProps = { }, notes: 'mockNotes', prerequisites: [] as PrerequisiteChallenge[], - removeComments: false, isLocked: false, isPrivate: false, order: 1, diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending.md index 4ad1e2c7910..b87f5fc9928 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string.md index 84b4b5dc65f..dbae3dde019 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/repeat-a-string-repeat-a-string.md @@ -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 `""`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/add-items-using-splice.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/add-items-using-splice.md index ec9575f325c..8477ae22407 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/add-items-using-splice.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/add-items-using-splice.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/add-key-value-pairs-to-javascript-objects.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/add-key-value-pairs-to-javascript-objects.md index 99f116debcc..8158c3eea52 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/add-key-value-pairs-to-javascript-objects.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/add-key-value-pairs-to-javascript-objects.md @@ -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 ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property.md index f5d95e40137..59f60d5472a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property.md @@ -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) ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.md index 7c0b9f2ea0f..6f20c63f701 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-array-items-using-slice.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-array-items-using-slice.md index 325439ea9a2..53005bd00eb 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-array-items-using-slice.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-array-items-using-slice.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for...in-statement.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for...in-statement.md index 5ce682a372c..7374a1198e2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for...in-statement.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for...in-statement.md @@ -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*\)/ ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/modify-an-object-nested-within-an-object.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/modify-an-object-nested-within-an-object.md index 731f95ff6ae..7bc4adb5993 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/modify-an-object-nested-within-an-object.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/modify-an-object-nested-within-an-object.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-using-splice.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-using-splice.md index f1b6ea28e5f..bc6fbd46a1b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-using-splice.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-using-splice.md @@ -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) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/use-the-delete-keyword-to-remove-object-properties.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/use-the-delete-keyword-to-remove-object-properties.md index 575e41f90aa..627ed9a5948 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/use-the-delete-keyword-to-remove-object-properties.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-data-structures/use-the-delete-keyword-to-remove-object-properties.md @@ -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 ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md index 774a661f7f5..5d5e9200567 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md @@ -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; diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/access-multi-dimensional-arrays-with-indexes.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/access-multi-dimensional-arrays-with-indexes.md index 134359ce86b..867e7736b9d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/access-multi-dimensional-arrays-with-indexes.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/access-multi-dimensional-arrays-with-indexes.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-arrays.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-arrays.md index 525977abeac..e5cf4fc9ef1 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-arrays.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-arrays.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-bracket-notation.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-bracket-notation.md index 41c08ea866f..6b15dffd25f 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-bracket-notation.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-bracket-notation.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-dot-notation.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-dot-notation.md index db9d63d3bb8..86dcd740f80 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-dot-notation.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-dot-notation.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-variables.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-variables.md index f509f03e7e7..dc370d28fb0 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-variables.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-variables.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md index ab0a9969e9b..a0281239d92 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-two-numbers-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-two-numbers-with-javascript.md index fc107f1b587..1d742e4d667 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-two-numbers-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/add-two-numbers-with-javascript.md @@ -38,7 +38,7 @@ assert(sum === 20); You should use the `+` operator. ```js -assert(/\+/.test(code)); +assert(/\+/.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements.md index 319770d14b9..48d98bf34e6 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings.md index 7b2d223a44f..f0c61a714f4 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assigning-the-value-of-one-variable-to-another.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assigning-the-value-of-one-variable-to-another.md index ad5a0371ab8..ed896f479f2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assigning-the-value-of-one-variable-to-another.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assigning-the-value-of-one-variable-to-another.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assignment-with-a-returned-value.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assignment-with-a-returned-value.md index a825bdf453a..e6e1ffcffe6 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assignment-with-a-returned-value.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/assignment-with-a-returned-value.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/chaining-if-else-statements.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/chaining-if-else-statements.md index 608723120c6..df451278269 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/chaining-if-else-statements.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/chaining-if-else-statements.md @@ -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` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code.md index a5f59ff63f0..5b6a9e09cc1 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code.md @@ -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 diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator.md index 8ef2dc27b8e..276b4c19d00 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-operator.md index 544d9f86fdb..292700753db 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.md index 3c0c64a793b..faf108fb241 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-inequality-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-inequality-operator.md index c8260cfe2fe..8a8f79c4b84 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-inequality-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-inequality-operator.md @@ -60,7 +60,7 @@ assert(testNotEqual('bob') === 'Not Equal'); You should use the `!=` operator ```js -assert(code.match(/(?!!==)!=/)); +assert(__helpers.removeJSComments(code).match(/(?!!==)!=/)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-operator.md index 8b7c5158fd8..d9b6893c63c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-or-equal-to-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-or-equal-to-operator.md index 55db0c27c7a..37e028eb9f7 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-or-equal-to-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-or-equal-to-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator.md index d0d14f64778..09d6fb81ad2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-inequality-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-inequality-operator.md index 9d2266e4636..c49a23991a0 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-inequality-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-inequality-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator.md index e6433fac0ad..c557b1056d3 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator.md @@ -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` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-or-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-or-operator.md index dba13a7dbc5..36178a26975 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-or-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-or-operator.md @@ -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` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md index 5e1db2e1405..f966d7484dd 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md @@ -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)) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-division.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-division.md index dc48677b84b..2e3c8f71086 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-division.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-division.md @@ -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)) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-multiplication.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-multiplication.md index 6d3a4fe3ee5..a9de30a6364 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-multiplication.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-multiplication.md @@ -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)) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-subtraction.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-subtraction.md index c81bab787b6..8fce85b5742 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-subtraction.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-subtraction.md @@ -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)) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md index 3aaeab380f7..78410226b6f 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator.md index 94201b36790..d47ee7fa973 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/constructing-strings-with-variables.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/constructing-strings-with-variables.md index ba170cf1d59..10f34a6c57b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/constructing-strings-with-variables.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/constructing-strings-with-variables.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop.md index fe00f54d76b..5b84a8227cf 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop.md @@ -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]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/declare-javascript-variables.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/declare-javascript-variables.md index 9d41fe9503c..102e882e976 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/declare-javascript-variables.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/declare-javascript-variables.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/decrement-a-number-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/decrement-a-number-with-javascript.md index 3c5cb464e6a..ff957dabcfc 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/decrement-a-number-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/decrement-a-number-with-javascript.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/delete-properties-from-a-javascript-object.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/delete-properties-from-a-javascript-object.md index 480148c2f4d..6e44fb6f219 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/delete-properties-from-a-javascript-object.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/delete-properties-from-a-javascript-object.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/divide-one-decimal-by-another-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/divide-one-decimal-by-another-with-javascript.md index 90732f0bd7d..0cc61567576 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/divide-one-decimal-by-another-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/divide-one-decimal-by-another-with-javascript.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/divide-one-number-by-another-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/divide-one-number-by-another-with-javascript.md index f5e9875ac42..38427a994fb 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/divide-one-number-by-another-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/divide-one-number-by-another-with-javascript.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/escaping-literal-quotes-in-strings.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/escaping-literal-quotes-in-strings.md index 21fcd4fe6eb..3f33d49c525 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/escaping-literal-quotes-in-strings.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/escaping-literal-quotes-in-strings.md @@ -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".` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/find-the-length-of-a-string.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/find-the-length-of-a-string.md index 28e463a453d..d17daa4c773 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/find-the-length-of-a-string.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/find-the-length-of-a-string.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript.md index c680879a8b2..6b5ba558c6e 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript.md @@ -39,7 +39,7 @@ Set `remainder` equal to the remainder of `11` divided by `3` using the 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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-fractions-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-fractions-with-javascript.md index 0a93e330620..b8bc6c1778b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-fractions-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-fractions-with-javascript.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md index df5743e2d44..04d87ba9c83 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-with-javascript.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-within-a-range.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-within-a-range.md index f9d999395ac..9f55b7dea17 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-within-a-range.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/generate-random-whole-numbers-within-a-range.md @@ -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 { diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/global-scope-and-functions.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/global-scope-and-functions.md index 5ee2aea4e86..cf501ba85f1 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/global-scope-and-functions.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/global-scope-and-functions.md @@ -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` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/global-vs.-local-scope-in-functions.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/global-vs.-local-scope-in-functions.md index d4ae646f40e..bf48ff49d1e 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/global-vs.-local-scope-in-functions.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/global-vs.-local-scope-in-functions.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript.md index 6f1b0031438..c11ae000e52 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator.md index 1fd59cdfff7..74dba02c291 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/initializing-variables-with-the-assignment-operator.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/introducing-else-if-statements.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/introducing-else-if-statements.md index 803a30f9c84..b844174c40f 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/introducing-else-if-statements.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/introducing-else-if-statements.md @@ -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*\}/ ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/introducing-else-statements.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/introducing-else-statements.md index 683f9a30b18..7348b6448eb 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/introducing-else-statements.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/introducing-else-statements.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-odd-numbers-with-a-for-loop.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-odd-numbers-with-a-for-loop.md index af1764e1738..47f86402e34 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-odd-numbers-with-a-for-loop.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-odd-numbers-with-a-for-loop.md @@ -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]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop.md index 9b1799d7840..36bbd457c0b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-do...while-loops.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-do...while-loops.md index af005afe4f1..84f8c48bf65 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-do...while-loops.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-do...while-loops.md @@ -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]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md index b530a42a31a..16d2ac028c2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md @@ -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]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-while-loops.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-while-loops.md index 27a209e3775..236f2fa714c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-while-loops.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-while-loops.md @@ -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]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/local-scope-and-functions.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/local-scope-and-functions.md index eb73b0f20f6..e36c0ab3819 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/local-scope-and-functions.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/local-scope-and-functions.md @@ -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)) ) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/manipulate-arrays-with-pop.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/manipulate-arrays-with-pop.md index d6f5760b016..b449b95ab25 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/manipulate-arrays-with-pop.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/manipulate-arrays-with-pop.md @@ -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]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/modify-array-data-with-indexes.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/modify-array-data-with-indexes.md index e2af9ff7abd..4f440c3c1d4 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/modify-array-data-with-indexes.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/modify-array-data-with-indexes.md @@ -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; diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiple-identical-options-in-switch-statements.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiple-identical-options-in-switch-statements.md index 3d1d4276242..a922470d8e2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiple-identical-options-in-switch-statements.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiple-identical-options-in-switch-statements.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiply-two-decimals-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiply-two-decimals-with-javascript.md index c1118c349f3..158c361ecdb 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiply-two-decimals-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiply-two-decimals-with-javascript.md @@ -28,7 +28,7 @@ assert(product === 5.0); You should use the `*` operator ```js -assert(/\*/.test(code)); +assert(/\*/.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiply-two-numbers-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiply-two-numbers-with-javascript.md index 98cff459984..94383a301e5 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiply-two-numbers-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/multiply-two-numbers-with-javascript.md @@ -36,7 +36,7 @@ assert(product === 80); You should use the `*` operator. ```js -assert(/\*/.test(code)); +assert(/\*/.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/passing-values-to-functions-with-arguments.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/passing-values-to-functions-with-arguments.md index 62795ccd42f..53f2940b537 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/passing-values-to-functions-with-arguments.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/passing-values-to-functions-with-arguments.md @@ -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, '') ) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/practice-comparing-different-values.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/practice-comparing-different-values.md index ee683c59fa1..a124c651b08 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/practice-comparing-different-values.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/practice-comparing-different-values.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/quoting-strings-with-single-quotes.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/quoting-strings-with-single-quotes.md index dc6b0959b9f..fa18defa6f7 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/quoting-strings-with-single-quotes.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/quoting-strings-with-single-quotes.md @@ -47,7 +47,7 @@ You should remove all the backslashes (`\`). ```js assert( - !/\\/g.test(code) && + !/\\/g.test(__helpers.removeJSComments(code)) && myStr.match( '\\s*\\s*Link\\s*\\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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion.md index e30e0a3018d..b38246305c5 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion.md @@ -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) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/replacing-if-else-chains-with-switch.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/replacing-if-else-chains-with-switch.md index b43ee5c811a..9b239123f07 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/replacing-if-else-chains-with-switch.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/replacing-if-else-chains-with-switch.md @@ -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` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/returning-boolean-values-from-functions.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/returning-boolean-values-from-functions.md index fbca53af739..862523365ac 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/returning-boolean-values-from-functions.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/returning-boolean-values-from-functions.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/selecting-from-many-options-with-switch-statements.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/selecting-from-many-options-with-switch-statements.md index 87f0ade0359..dd61469c08d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/selecting-from-many-options-with-switch-statements.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/selecting-from-many-options-with-switch-statements.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator.md index 8c946f1c2d2..22ab4be5e44 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator.md @@ -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. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/subtract-one-number-from-another-with-javascript.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/subtract-one-number-from-another-with-javascript.md index 83508131f07..5ef318c8e56 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/subtract-one-number-from-another-with-javascript.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/subtract-one-number-from-another-with-javascript.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understand-string-immutability.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understand-string-immutability.md index 2564240ae8c..8e189327f7a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understand-string-immutability.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understand-string-immutability.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understanding-case-sensitivity-in-variables.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understanding-case-sensitivity-in-variables.md index 93c8577ac67..1645b3846f6 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understanding-case-sensitivity-in-variables.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understanding-case-sensitivity-in-variables.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables.md index 27fe3157eec..1d6dc81ef4e 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables.md @@ -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)) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/updating-object-properties.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/updating-object-properties.md index 1fed807aff3..730c224be61 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/updating-object-properties.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/updating-object-properties.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-first-character-in-a-string.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-first-character-in-a-string.md index ff334faf2cf..bb362ea62b1 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-first-character-in-a-string.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-first-character-in-a-string.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-last-character-in-a-string.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-last-character-in-a-string.md index b2c4ce8d478..e433f67a70a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-last-character-in-a-string.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-last-character-in-a-string.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-character-in-a-string.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-character-in-a-string.md index b5cd43bef41..6d208672baf 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-character-in-a-string.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-character-in-a-string.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-to-last-character-in-a-string.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-to-last-character-in-a-string.md index db3391361ed..7f507243a94 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-to-last-character-in-a-string.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-to-last-character-in-a-string.md @@ -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-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-multiple-conditional-ternary-operators.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-multiple-conditional-ternary-operators.md index 48521473393..fb4eb8b0386 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-multiple-conditional-ternary-operators.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-multiple-conditional-ternary-operators.md @@ -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 diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown.md index 36dd7bcbf98..e57a13d85af 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-countdown.md @@ -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) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers.md index c1d664f2baf..f0705fa2a4f 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-recursion-to-create-a-range-of-numbers.md @@ -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) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-conditional-ternary-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-conditional-ternary-operator.md index cca85c335f3..475aeb74a31 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-conditional-ternary-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-conditional-ternary-operator.md @@ -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` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function-with-a-radix.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function-with-a-radix.md index 392131577e9..aadb827669c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function-with-a-radix.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function-with-a-radix.md @@ -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 diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function.md index bb0b4b00926..28336f002e2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function.md @@ -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 diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups.md index 0f879f74f7b..9f4ec2d2980 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups.md @@ -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, '')) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/word-blanks.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/word-blanks.md index 0f519ae9a5d..e9f6883ef80 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/word-blanks.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/word-blanks.md @@ -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) && diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/write-reusable-javascript-with-functions.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/write-reusable-javascript-with-functions.md index 2a62b70ea4f..97fe0e88005 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/write-reusable-javascript-with-functions.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/write-reusable-javascript-with-functions.md @@ -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)); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-arguments-passed-in-the-wrong-order-when-calling-a-function.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-arguments-passed-in-the-wrong-order-when-calling-a-function.md index 7aea16b1e6b..25744faaff1 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-arguments-passed-in-the-wrong-order-when-calling-a-function.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-arguments-passed-in-the-wrong-order-when-calling-a-function.md @@ -25,7 +25,7 @@ assert(power == 8); Your code should use the correct order of the arguments for the `raiseToPower` function call. ```js -assert(code.match(/raiseToPower\(\s*?base\s*?,\s*?exp\s*?\);/g)); +assert(__helpers.removeJSComments(code).match(/raiseToPower\(\s*?base\s*?,\s*?exp\s*?\);/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-missing-open-and-closing-parenthesis-after-a-function-call.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-missing-open-and-closing-parenthesis-after-a-function-call.md index 83f757ada16..fa042698c88 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-missing-open-and-closing-parenthesis-after-a-function-call.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-missing-open-and-closing-parenthesis-after-a-function-call.md @@ -37,7 +37,7 @@ assert(result == 9); Your code should call the `getNine` function. ```js -assert(code.match(/getNine\(\)/g).length == 2); +assert(__helpers.removeJSComments(code).match(/getNine\(\)/g).length == 2); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-misspelled-variable-and-function-names.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-misspelled-variable-and-function-names.md index c0795c6ea6f..bcbfad11dea 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-misspelled-variable-and-function-names.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-misspelled-variable-and-function-names.md @@ -27,25 +27,25 @@ assert(netWorkingCapital === 2); There should be no instances of misspelled variables in the code. ```js -assert(!code.match(/recievables/g)); +assert(!__helpers.removeJSComments(code).match(/recievables/g)); ``` The `receivables` variable should be declared and used properly in the code. ```js -assert(code.match(/receivables/g).length == 2); +assert(__helpers.removeJSComments(code).match(/receivables/g).length == 2); ``` There should be no instances of misspelled variables in the code. ```js -assert(!code.match(/payable;/g)); +assert(!__helpers.removeJSComments(code).match(/payable;/g)); ``` The `payables` variable should be declared and used properly in the code. ```js -assert(code.match(/payables/g).length == 2); +assert(__helpers.removeJSComments(code).match(/payables/g).length == 2); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-mixed-usage-of-single-and-double-quotes.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-mixed-usage-of-single-and-double-quotes.md index 90d6fcd9581..8cd7fce770f 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-mixed-usage-of-single-and-double-quotes.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-mixed-usage-of-single-and-double-quotes.md @@ -37,13 +37,13 @@ Fix the string so it either uses different quotes for the `href` value, or escap Your code should fix the quotes around the `href` value `#Home` by either changing or escaping them. ```js -assert(code.match(//g)); +assert(__helpers.removeJSComments(code).match(//g)); ``` Your code should keep the double quotes around the entire string. ```js -assert(code.match(/"

.*?<\/p>";/g)); +assert(__helpers.removeJSComments(code).match(/"

.*?<\/p>";/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing.md index e0ccc7ba4d2..1c29cf7a8ea 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing.md @@ -37,25 +37,25 @@ Fix the two indexing errors in the following function so all the numbers 1 throu Your code should set the initial condition of the loop so it starts at the first index. ```js -assert(code.match(/i\s*?=\s*?0\s*?;/g).length == 1); +assert(__helpers.removeJSComments(code).match(/i\s*?=\s*?0\s*?;/g).length == 1); ``` Your code should fix the initial condition of the loop so that the index starts at 0. ```js -assert(!code.match(/i\s?=\s*?1\s*?;/g)); +assert(!__helpers.removeJSComments(code).match(/i\s?=\s*?1\s*?;/g)); ``` Your code should set the terminal condition of the loop so it stops at the last index. ```js -assert(code.match(/i\s*<\s*len\s*;|i\s*<=\s*len\s*-\s*1\s*;/g).length == 1); +assert(__helpers.removeJSComments(code).match(/i\s*<\s*len\s*;|i\s*<=\s*len\s*-\s*1\s*;/g).length == 1); ``` Your code should fix the terminal condition of the loop so that it stops at 1 before the length. ```js -assert(!code.match(/i\s*?<=\s*?len;/g)); +assert(!__helpers.removeJSComments(code).match(/i\s*?<=\s*?len;/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes.md index 42ad053023c..174e004e94a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes.md @@ -21,7 +21,7 @@ Fix the two pair errors in the code. Your code should fix the missing piece of the array. ```js -assert(code.match(/myArray\s*?=\s*?\[\s*?1\s*?,\s*?2\s*?,\s*?3\s*?\];/g)); +assert(__helpers.removeJSComments(code).match(/myArray\s*?=\s*?\[\s*?1\s*?,\s*?2\s*?,\s*?3\s*?\];/g)); ``` Your code should fix the missing piece of the `.reduce()` method. The console output should show that `Sum of array values is: 6`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-use-of-assignment-operator-instead-of-equality-operator.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-use-of-assignment-operator-instead-of-equality-operator.md index 7fea55d1857..bdb5b446fa0 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-use-of-assignment-operator-instead-of-equality-operator.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-use-of-assignment-operator-instead-of-equality-operator.md @@ -43,7 +43,7 @@ assert(result == 'Not equal!'); The condition should use either `==` or `===` to test for equality. ```js -assert(code.match(/x\s*?===?\s*?y/g)); +assert(__helpers.removeJSComments(code).match(/x\s*?===?\s*?y/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/prevent-infinite-loops-with-a-valid-terminal-condition.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/prevent-infinite-loops-with-a-valid-terminal-condition.md index 9455e136450..bc754ef04be 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/prevent-infinite-loops-with-a-valid-terminal-condition.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/prevent-infinite-loops-with-a-valid-terminal-condition.md @@ -31,13 +31,13 @@ The `myFunc()` function contains an infinite loop because the terminal condition Your code should change the comparison operator in the terminal condition (the middle part) of the `for` loop. ```js -assert(code.match(/i\s*?<=\s*?4;/g).length == 1); +assert(__helpers.removeJSComments(code).match(/i\s*?<=\s*?4;/g).length == 1); ``` Your code should fix the comparison operator in the terminal condition of the loop. ```js -assert(!code.match(/i\s*?!=\s*?4;/g)); +assert(!__helpers.removeJSComments(code).match(/i\s*?!=\s*?4;/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md index cb849f0678c..e1a156d6d87 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md @@ -23,7 +23,7 @@ After that, use `console.log` to log the `output` variable. View the two console You should use `console.log()` to print the `output` variable. ```js -assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); +assert(__helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/console\.log\(output\)/)); ``` You should use `console.clear()` to clear the browser console. @@ -31,7 +31,7 @@ You should use `console.clear()` to clear the browser console. ```js assert( __helpers - .removeWhiteSpace(code) + .removeWhiteSpace(__helpers.removeJSComments(code)) .match(/console.clear\(\)/) ); ``` @@ -41,7 +41,7 @@ You should clear the console after your log. ```js assert( __helpers - .removeWhiteSpace(code) + .removeWhiteSpace(__helpers.removeJSComments(code)) .match(/console\.log\(output\)[\s\S]*console.clear\(\)/) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md index 4e212c27230..e0572d55c49 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md @@ -29,7 +29,7 @@ Use the `console.log()` method to print the value of the variable `a` where note Your code should use `console.log()` to check the value of the variable `a`. ```js -assert(code.match(/console\.log\(a\)/g)); +assert(__helpers.removeJSComments(code).match(/console\.log\(a\)/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-typeof-to-check-the-type-of-a-variable.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-typeof-to-check-the-type-of-a-variable.md index 4a665970ce0..b4c2503d024 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-typeof-to-check-the-type-of-a-variable.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/use-typeof-to-check-the-type-of-a-variable.md @@ -32,19 +32,19 @@ Add two `console.log()` statements to check the `typeof` each of the two variabl Your code should use `typeof` in two `console.log()` statements to check the type of the variables. ```js -assert(code.match(/console\.log\s*\(typeof[\( ].*\)?\)/g).length == 2); +assert(__helpers.removeJSComments(code).match(/console\.log\s*\(typeof[\( ].*\)?\)/g).length == 2); ``` Your code should use `typeof` to check the type of the variable `seven`. ```js -assert(code.match(/typeof[\( ]seven\)?/g)); +assert(__helpers.removeJSComments(code).match(/typeof[\( ]seven\)?/g)); ``` Your code should use `typeof` to check the type of the variable `three`. ```js -assert(code.match(/typeof[\( ]three\)?/g)); +assert(__helpers.removeJSComments(code).match(/typeof[\( ]three\)?/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords.md index 2a8bde1fca8..45454346297 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords.md @@ -87,13 +87,13 @@ This exercise is designed to illustrate the difference between how `var` and `le `var` should not exist in code. ```js -assert(!code.match(/var/g)); +assert(!__helpers.removeJSComments(code).match(/var/g)); ``` The variable `i` declared in the `if` statement should equal the string `block scope`. ```js -assert(code.match(/(i\s*=\s*).*\s*.*\s*.*\1('|")block\s*scope\2/g)); +assert(__helpers.removeJSComments(code).match(/(i\s*=\s*).*\s*.*\s*.*\1('|")block\s*scope\2/g)); ``` `checkScope()` should return the string `function scope` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/complete-a-promise-with-resolve-and-reject.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/complete-a-promise-with-resolve-and-reject.md index 83fb671b57c..5b72fd89bb1 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/complete-a-promise-with-resolve-and-reject.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/complete-a-promise-with-resolve-and-reject.md @@ -32,7 +32,7 @@ Make the promise handle success and failure. If `responseFromServer` is `true`, ```js assert( - code.match(/if\s*\(\s*responseFromServer\s*\)\s*{\s*resolve\s*\(\s*('|"|`)We got the data\1\s*\)(\s*|\s*;\s*)}/g) + __helpers.removeJSComments(code).match(/if\s*\(\s*responseFromServer\s*\)\s*{\s*resolve\s*\(\s*('|"|`)We got the data\1\s*\)(\s*|\s*;\s*)}/g) ); ``` @@ -40,7 +40,7 @@ assert( ```js assert( - code.match(/}\s*else\s*{\s*reject\s*\(\s*('|"|`)Data not received\1\s*\)(\s*|\s*;\s*)}/g) + __helpers.removeJSComments(code).match(/}\s*else\s*{\s*reject\s*\(\s*('|"|`)Data not received\1\s*\)(\s*|\s*;\s*)}/g) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.md index 664d8a09303..d4dd94e7047 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.md @@ -32,7 +32,7 @@ Your promise should receive a function with `resolve` and `reject` as parameters ```js assert( - code.match( + __helpers.removeJSComments(code).match( /Promise\s*\(\s*(function\s*\(\s*resolve\s*,\s*reject\s*\)\s*{|\(\s*resolve\s*,\s*reject\s*\)\s*=>\s*{)[^}]*}/g ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.md index 30959b42a3c..d4964d1b073 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.md @@ -25,14 +25,14 @@ Add a script to the HTML document of type `module` and give it the source file o You should create a `script` tag. ```js -assert(code.match(/<\s*script[^>]*>\s*<\/\s*script\s*>/g)); +assert(__helpers.removeJSComments(code).match(/<\s*script[^>]*>\s*<\/\s*script\s*>/g)); ``` Your `script` tag should have the `type` attribute with a value of `module`. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /<\s*script\s+[^t]*type\s*=\s*('|")module\1[^>]*>\s*<\/\s*script\s*>/g ) ); @@ -42,7 +42,7 @@ Your `script` tag should have a `src` of `index.js`. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /<\s*script\s+[^s]*src\s*=\s*('|")index\.js\1[^>]*>\s*<\/\s*script\s*>/g ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default.md index 0f4d9c3390b..4461a51d4d0 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default.md @@ -38,7 +38,7 @@ Your code should use an `export` fallback. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /export\s+default\s+function(\s+subtract\s*|\s*)\(\s*x,\s*y\s*\)\s*{/g ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md index 22e02de6657..e3691452a84 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md @@ -75,7 +75,7 @@ assert.match(code, /(`.*\${.*}.*`)/); An iterator should be used. ```js -assert(code.match(/for|map|reduce|forEach|while/)); +assert(__helpers.removeJSComments(code).match(/for|map|reduce|forEach|while/)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/handle-a-fulfilled-promise-with-then.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/handle-a-fulfilled-promise-with-then.md index d95b8d962dc..adce955322d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/handle-a-fulfilled-promise-with-then.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/handle-a-fulfilled-promise-with-then.md @@ -34,7 +34,7 @@ You should call the `then` method on the promise. ```js assert( - __helpers.removeWhiteSpace(code).match(/(makeServerRequest|\))\.then\(/g) + __helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/(makeServerRequest|\))\.then\(/g) ); ``` @@ -50,7 +50,7 @@ You should log `result` to the console. assert( resultIsParameter && __helpers - .removeWhiteSpace(code) + .removeWhiteSpace(__helpers.removeJSComments(code)) .match(/\.then\(.*?result.*?console.log\(result\).*?\)/) ); ``` @@ -60,7 +60,7 @@ assert( ## --after-user-code-- ```js -const resultIsParameter = /\.then\((function\(result\){|result|\(result\)=>)/.test(__helpers.removeWhiteSpace(code)); +const resultIsParameter = /\.then\((function\(result\){|result|\(result\)=>)/.test(__helpers.removeWhiteSpace(__helpers.removeJSComments(code))); ``` ## --seed-contents-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/handle-a-rejected-promise-with-catch.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/handle-a-rejected-promise-with-catch.md index a0ac218b643..51a210f88d8 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/handle-a-rejected-promise-with-catch.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/handle-a-rejected-promise-with-catch.md @@ -28,7 +28,7 @@ You should call the `catch` method on the promise. ```js assert( - __helpers.removeWhiteSpace(code).match(/(makeServerRequest|\))\.catch\(/g) + __helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/(makeServerRequest|\))\.catch\(/g) ); ``` @@ -44,7 +44,7 @@ You should log `error` to the console. assert( errorIsParameter && __helpers - .removeWhiteSpace(code) + .removeWhiteSpace(__helpers.removeJSComments(code)) .match(/\.catch\(.*?error.*?console.log\(error\).*?\)/) ); ``` @@ -54,7 +54,7 @@ assert( ## --after-user-code-- ```js -const errorIsParameter = /\.catch\((function\(error\){|error|\(error\)=>)/.test(__helpers.removeWhiteSpace(code)); +const errorIsParameter = /\.catch\((function\(error\){|error|\(error\)=>)/.test(__helpers.removeWhiteSpace(__helpers.removeJSComments(code))); ``` ## --seed-contents-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/import-a-default-export.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/import-a-default-export.md index 115ad02bd70..6a70884d806 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/import-a-default-export.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/import-a-default-export.md @@ -25,7 +25,7 @@ In the following code, import the default export from the `math_functions.js` fi You should properly import `subtract` from `math_functions.js`. ```js -assert(code.match(/import\s+subtract\s+from\s+('|")\.\/math_functions\.js\1/g)); +assert(__helpers.removeJSComments(code).match(/import\s+subtract\s+from\s+('|")\.\/math_functions\.js\1/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md index 45e1bf50d4a..b8959ccd03d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md @@ -36,19 +36,19 @@ An array is declared as `const s = [5, 7, 2]`. Change the array to `[2, 5, 7]` u You should not replace `const` keyword. ```js -assert(code.match(/const/g)); +assert(__helpers.removeJSComments(code).match(/const/g)); ``` `s` should be a constant variable (by using `const`). ```js -assert(code.match(/const\s+s/g)); +assert(__helpers.removeJSComments(code).match(/const\s+s/g)); ``` You should not change the original array declaration. ```js -assert(code.match( +assert(__helpers.removeJSComments(code).match( /const\s+s\s*=\s*\[\s*5\s*,\s*7\s*,\s*2\s*\]\s*;?/g )); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md index 81871af4d84..2ccc4562475 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md @@ -34,19 +34,19 @@ In this challenge you are going to use `Object.freeze` to prevent mathematical c You should not replace the `const` keyword. ```js -assert(code.match(/const/g)); +assert(__helpers.removeJSComments(code).match(/const/g)); ``` `MATH_CONSTANTS` should be a constant variable (by using `const`). ```js -assert(code.match(/const\s+MATH_CONSTANTS/g)); +assert(__helpers.removeJSComments(code).match(/const\s+MATH_CONSTANTS/g)); ``` You should not change the original declaration of `MATH_CONSTANTS`. ```js -assert(code.match( +assert(__helpers.removeJSComments(code).match( /const\s+MATH_CONSTANTS\s+=\s+{\s+PI:\s+3.14\s+};/g )); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/reuse-javascript-code-using-import.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/reuse-javascript-code-using-import.md index 1a21ddbb05a..bcde2f4d744 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/reuse-javascript-code-using-import.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/reuse-javascript-code-using-import.md @@ -32,7 +32,7 @@ You should properly import `uppercaseString`. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /import\s*{\s*(uppercaseString[^}]*|[^,]*,\s*uppercaseString\s*)}\s+from\s+('|")\.\/string_functions\.js\2/g ) ); @@ -42,7 +42,7 @@ You should properly import `lowercaseString`. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /import\s*{\s*(lowercaseString[^}]*|[^,]*,\s*lowercaseString\s*)}\s+from\s+('|")\.\/string_functions\.js\2/g ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions.md index 0bb3fd12f27..d274ece607e 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions.md @@ -44,7 +44,7 @@ assert(increment(5) === 6); A default parameter value of `1` should be used for `value`. ```js -assert(code.match(/value\s*=\s*1/g)); +assert(__helpers.removeJSComments(code).match(/value\s*=\s*1/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file.md index c990788c45a..7c68ab7bc5b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file.md @@ -31,7 +31,7 @@ Your code should properly use `import * as` syntax. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /import\s*\*\s*as\s+stringFunctions\s+from\s*('|")\.\/string_functions\.js\1/g ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function.md index 6ac1354551d..79757f26c3d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function.md @@ -66,7 +66,7 @@ assert( The `class` keyword should be used. ```js -assert(code.match(/class/g)); +assert(__helpers.removeJSComments(code).match(/class/g)); ``` `Vegetable` should be able to be instantiated. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md index 06603733844..15fd81f95d8 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md @@ -51,7 +51,7 @@ assert(b === 8); You should use array destructuring to swap `a` and `b`. ```js -assert(/\[\s*(\w)\s*,\s*(\w)\s*\]\s*=\s*\[\s*\2\s*,\s*\1\s*\]/g.test(code)); +assert(/\[\s*(\w)\s*,\s*(\w)\s*\]\s*=\s*\[\s*\2\s*,\s*\1\s*\]/g.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md index 3dcbfef5d5f..a0532bd35be 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md @@ -43,8 +43,8 @@ You should remove the ES5 assignment syntax. ```js assert( - !code.match(/lowToday = LOCAL_FORECAST\.today\.low/g) && - !code.match(/highToday = LOCAL_FORECAST\.today.high/g) + !__helpers.removeJSComments(code).match(/lowToday = LOCAL_FORECAST\.today\.low/g) && + !__helpers.removeJSComments(code).match(/highToday = LOCAL_FORECAST\.today.high/g) ); ``` @@ -52,7 +52,7 @@ You should use destructuring to create the `lowToday` variable. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /(var|const|let)\s*{\s*today\s*:\s*{\s*(low\s*:\s*lowToday[^}]*|[^,]*,\s*low\s*:\s*lowToday\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); @@ -62,7 +62,7 @@ You should use destructuring to create the `highToday` variable. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /(var|const|let)\s*{\s*today\s*:\s*{\s*(high\s*:\s*highToday[^}]*|[^,]*,\s*high\s*:\s*highToday,?\s*)},?\s*}\s*=\s*LOCAL_FORECAST(;|\s+|\/\/)/g ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.md index e14f1624a63..aa3c7e4b048 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.md @@ -34,8 +34,8 @@ You should remove the ES5 assignment syntax. ```js assert( - !code.match(/highToday = HIGH_TEMPERATURES\.today/g) && - !code.match(/highTomorrow = HIGH_TEMPERATURES\.tomorrow/g) + !__helpers.removeJSComments(code).match(/highToday = HIGH_TEMPERATURES\.today/g) && + !__helpers.removeJSComments(code).match(/highTomorrow = HIGH_TEMPERATURES\.tomorrow/g) ); ``` @@ -43,7 +43,7 @@ You should use destructuring to create the `highToday` variable. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /(var|const|let)\s*{\s*(today\s*:\s*highToday[^}]*|[^,]*,\s*today\s*:\s*highToday\s*)}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g ) ); @@ -53,7 +53,7 @@ You should use destructuring to create the `highTomorrow` variable. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /(var|const|let)\s*{\s*(tomorrow\s*:\s*highTomorrow[^}]*|[^,]*,\s*tomorrow\s*:\s*highTomorrow\s*)}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.md index 5d71f583488..fa6536ed622 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.md @@ -43,7 +43,7 @@ You should remove the ES5 assignment syntax. ```js assert( - !code.match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g) + !__helpers.removeJSComments(code).match(/today\s*=\s*HIGH_TEMPERATURES\.(today|tomorrow)/g) ); ``` @@ -51,7 +51,7 @@ You should use destructuring to create the `today` variable. ```js assert( - code.match(/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g) + __helpers.removeJSComments(code).match(/(var|let|const)\s*{\s*(today[^}]*|[^,]*,\s*today)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g) ); ``` @@ -59,7 +59,7 @@ You should use destructuring to create the `tomorrow` variable. ```js assert( - code.match(/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g) + __helpers.removeJSComments(code).match(/(var|let|const)\s*{\s*(tomorrow[^}]*|[^,]*,\s*tomorrow)\s*}\s*=\s*HIGH_TEMPERATURES(;|\s+|\/\/)/g) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.md index 5e5d98d9ad4..b854c6d6963 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.md @@ -50,13 +50,13 @@ assert(half(stats) === 28.015); Destructuring should be used. ```js -assert(__helpers.removeWhiteSpace(code).match(/half=\({\w+,\w+}\)/)); +assert(__helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/half=\({\w+,\w+}\)/)); ``` Destructured parameter should be used. ```js -assert(!code.match(/stats\.max|stats\.min/)); +assert(!__helpers.removeJSComments(code).match(/stats\.max|stats\.min/)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md index 31b4e1cecf2..3b292c14093 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md @@ -47,7 +47,7 @@ assert.deepEqual(_testArr, [1, 2, 3, 4, 5]) `Array.slice()` should not be used. ```js -assert(!code.match(/\.\s*slice\s*\(/)); +assert(!__helpers.removeJSComments(code).match(/\.\s*slice\s*\(/)); ``` You should use the rest syntax. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.md index cffcbbe642a..aced8c3e666 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.md @@ -42,7 +42,7 @@ You should properly export `uppercaseString`. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /(export\s+const\s+uppercaseString|export\s*{\s*(uppercaseString[^}]*|[^,]*,\s*uppercaseString\s*)})/g ) ); @@ -52,7 +52,7 @@ You should properly export `lowercaseString`. ```js assert( - code.match( + __helpers.removeJSComments(code).match( /(export\s+const\s+lowercaseString|export\s*{\s*(lowercaseString[^}]*|[^,]*,\s*lowercaseString\s*)})/g ) ); diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.md index 3662a2a5b6a..16419359312 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.md @@ -57,7 +57,7 @@ assert(sum() === 0); `sum` should be an arrow function which uses the rest parameter syntax (`...`) on the `args` parameter. ```js -assert(__helpers.removeWhiteSpace(code).match(/sum=\(\.\.\.args\)=>/)); +assert(__helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/sum=\(\.\.\.args\)=>/)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place.md index a1459ca284e..fdec08a18ac 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place.md @@ -55,7 +55,7 @@ assert(arr2.every((v, i) => v === arr1[i]) && arr2.length); `...` spread operator should be used to duplicate `arr1`. ```js -assert(code.match(/Array\(\s*\.\.\.arr1\s*\)|\[\s*\.\.\.arr1\s*\]/)); +assert(__helpers.removeJSComments(code).match(/Array\(\s*\.\.\.arr1\s*\)|\[\s*\.\.\.arr1\s*\]/)); ``` `arr2` should remain unchanged when `arr1` is changed. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters.md index b69719ca7b6..dacd988e3b1 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters.md @@ -54,7 +54,7 @@ assert.match(code, /const\s+myConcat/g); ```js assert( - /myConcat=\(\w+,\w+\)=>/.test(code.replace(/\s/g, '')) && + /myConcat=\(\w+,\w+\)=>/.test(__helpers.removeJSComments(code).replace(/\s/g, '')) && typeof myConcat === 'function' ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md index 358e8df5ea9..973013765c9 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md @@ -39,14 +39,14 @@ Refactor the function `setGear` inside the object `bicycle` to use the shorthand Traditional function expression should not be used. ```js -assert(!code.match(/function/)); +assert(!__helpers.removeJSComments(code).match(/function/)); ``` `setGear` should be a declarative function. ```js assert( - typeof bicycle.setGear === 'function' && code.match(/setGear\s*\(.+\)\s*\{/) + typeof bicycle.setGear === 'function' && __helpers.removeJSComments(code).match(/setGear\s*\(.+\)\s*\{/) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md index 5841f2d195e..698e8f8b27b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md @@ -43,7 +43,7 @@ assert.deepEqual( Your code should not use `key:value`. ```js -assert(!code.match(/:/g)) +assert(!__helpers.removeJSComments(code).match(/:/g)) ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/add-elements-to-the-end-of-an-array-using-concat-instead-of-push.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/add-elements-to-the-end-of-an-array-using-concat-instead-of-push.md index 2ed704595e3..825ddecc5e7 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/add-elements-to-the-end-of-an-array-using-concat-instead-of-push.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/add-elements-to-the-end-of-an-array-using-concat-instead-of-push.md @@ -30,13 +30,13 @@ Change the `nonMutatingPush` function so it uses `concat` to merge `newItem` to Your code should use the `concat` method. ```js -assert(code.match(/\.concat/g)); +assert(__helpers.removeJSComments(code).match(/\.concat/g)); ``` Your code should not use the `push` method. ```js -assert(!code.match(/\.?[\s\S]*?push/g)); +assert(!__helpers.removeJSComments(code).match(/\.?[\s\S]*?push/g)); ``` The `first` array should not change. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs.md index 8023a0f9914..a47af76189d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/apply-functional-programming-to-convert-strings-to-url-slugs.md @@ -31,7 +31,7 @@ The output should not have any spaces Your code should not use the `replace` method for this challenge. ```js -assert(!code.match(/\.?[\s\S]*?replace/g)); +assert(!__helpers.removeJSComments(code).match(/\.?[\s\S]*?replace/g)); ``` `urlSlug("Winter Is Coming")` should return the string `winter-is-coming`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/combine-an-array-into-a-string-using-the-join-method.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/combine-an-array-into-a-string-using-the-join-method.md index 639900381dd..48955e87d5a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/combine-an-array-into-a-string-using-the-join-method.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/combine-an-array-into-a-string-using-the-join-method.md @@ -27,13 +27,13 @@ Use the `join` method (among others) inside the `sentensify` function to make a Your code should use the `join` method. ```js -assert(code.match(/\.join/g)); +assert(__helpers.removeJSComments(code).match(/\.join/g)); ``` Your code should not use the `replace` method. ```js -assert(!code.match(/\.?[\s\S]*?replace/g)); +assert(!__helpers.removeJSComments(code).match(/\.?[\s\S]*?replace/g)); ``` `sentensify("May-the-force-be-with-you")` should return a string. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/combine-two-arrays-using-the-concat-method.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/combine-two-arrays-using-the-concat-method.md index 18e42098bc3..1f85418eb66 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/combine-two-arrays-using-the-concat-method.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/combine-two-arrays-using-the-concat-method.md @@ -25,7 +25,7 @@ Use the `concat` method in the `nonMutatingConcat` function to concatenate `atta Your code should use the `concat` method. ```js -assert(code.match(/\.concat/g)); +assert(__helpers.removeJSComments(code).match(/\.concat/g)); ``` The `first` array should not change. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/implement-map-on-a-prototype.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/implement-map-on-a-prototype.md index 5d639253214..2c7324a123d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/implement-map-on-a-prototype.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/implement-map-on-a-prototype.md @@ -47,7 +47,7 @@ assert(JSON.stringify(_test_s.map(_callback)) === JSON.stringify(_test_s.myMap(_ Your code should not use the `map` method. ```js -assert(!code.match(/\.?[\s\S]*?map/g)); +assert(!__helpers.removeJSComments(code).match(/\.?[\s\S]*?map/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/implement-the-filter-method-on-a-prototype.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/implement-the-filter-method-on-a-prototype.md index 5dd410b9d01..120acd331c2 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/implement-the-filter-method-on-a-prototype.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/implement-the-filter-method-on-a-prototype.md @@ -43,7 +43,7 @@ assert(JSON.stringify(_test_s.filter(_callback)) === JSON.stringify(_test_s.myFi Your code should not use the `filter` method. ```js -assert(!code.match(/\.?[\s\S]*?filter/g)); +assert(!__helpers.removeJSComments(code).match(/\.?[\s\S]*?filter/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/introduction-to-currying-and-partial-application.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/introduction-to-currying-and-partial-application.md index efa43ab8a23..cdb646ad31e 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/introduction-to-currying-and-partial-application.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/introduction-to-currying-and-partial-application.md @@ -77,7 +77,7 @@ assert(add(11)(22)(33) === 66); Your code should include a final statement that returns `x + y + z`. ```js -assert(code.match(/[xyz]\s*?\+\s*?[xyz]\s*?\+\s*?[xyz]/g)); +assert(__helpers.removeJSComments(code).match(/[xyz]\s*?\+\s*?[xyz]\s*?\+\s*?[xyz]/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/remove-elements-from-an-array-using-slice-instead-of-splice.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/remove-elements-from-an-array-using-slice-instead-of-splice.md index 7b67c284b42..27f925aa552 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/remove-elements-from-an-array-using-slice-instead-of-splice.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/remove-elements-from-an-array-using-slice-instead-of-splice.md @@ -30,13 +30,13 @@ Do not mutate the original array provided to the function. Your code should use the `slice` method. ```js -assert(code.match(/\.slice/g)); +assert(__helpers.removeJSComments(code).match(/\.slice/g)); ``` Your code should not use the `splice` method. ```js -assert(!code.match(/\.?[\s\S]*?splice/g)); +assert(!__helpers.removeJSComments(code).match(/\.?[\s\S]*?splice/g)); ``` You should not mutate the original array passed to the function. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/return-part-of-an-array-using-the-slice-method.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/return-part-of-an-array-using-the-slice-method.md index ad25ac3ca30..3dbbb9c586c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/return-part-of-an-array-using-the-slice-method.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/return-part-of-an-array-using-the-slice-method.md @@ -28,7 +28,7 @@ Use the `slice` method in the `sliceArray` function to return part of the `anim` Your code should use the `slice` method. ```js -assert(code.match(/\.slice/g)); +assert(__helpers.removeJSComments(code).match(/\.slice/g)); ``` The `inputAnim` variable should not change. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method.md index 0dcf521c245..c57e31d884d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/sort-an-array-alphabetically-using-the-sort-method.md @@ -47,7 +47,7 @@ Use the `sort` method in the `alphabeticalOrder` function to sort the elements o Your code should use the `sort` method. ```js -assert(code.match(/\.sort/g)); +assert(__helpers.removeJSComments(code).match(/\.sort/g)); ``` `alphabeticalOrder(["a", "d", "c", "a", "z", "g"])` should return `["a", "a", "c", "d", "g", "z"]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/split-a-string-into-an-array-using-the-split-method.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/split-a-string-into-an-array-using-the-split-method.md index 790a15b15e3..8f6492382c5 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/split-a-string-into-an-array-using-the-split-method.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/split-a-string-into-an-array-using-the-split-method.md @@ -33,7 +33,7 @@ Use the `split` method inside the `splitify` function to split `str` into an arr Your code should use the `split` method. ```js -assert(code.match(/\.split/g)); +assert(__helpers.removeJSComments(code).match(/\.split/g)); ``` `splitify("Hello World,I-am code")` should return `["Hello", "World", "I", "am", "code"]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-higher-order-functions-map-filter-or-reduce-to-solve-a-complex-problem.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-higher-order-functions-map-filter-or-reduce-to-solve-a-complex-problem.md index 3b80b6677c1..da62f91a2ab 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-higher-order-functions-map-filter-or-reduce-to-solve-a-complex-problem.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-higher-order-functions-map-filter-or-reduce-to-solve-a-complex-problem.md @@ -28,7 +28,7 @@ assert.typeOf(squareList, 'function'), `for`, `while`, and `forEach` should not be used. ```js -assert(!code.match(/for|while|forEach/g)); +assert(!__helpers.removeJSComments(code).match(/for|while|forEach/g)); ``` `map`, `filter`, or `reduce` should be used. @@ -36,7 +36,7 @@ assert(!code.match(/for|while|forEach/g)); ```js assert( __helpers - .removeWhiteSpace(code) + .removeWhiteSpace(__helpers.removeJSComments(code)) .match(/\.(map|filter|reduce)\(/g) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-every-method-to-check-that-every-element-in-an-array-meets-a-criteria.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-every-method-to-check-that-every-element-in-an-array-meets-a-criteria.md index 61942f19549..d9e99d6855b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-every-method-to-check-that-every-element-in-an-array-meets-a-criteria.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-every-method-to-check-that-every-element-in-an-array-meets-a-criteria.md @@ -31,7 +31,7 @@ Use the `every` method inside the `checkPositive` function to check if every ele Your code should use the `every` method. ```js -assert(code.match(/\.every/g)); +assert(__helpers.removeJSComments(code).match(/\.every/g)); ``` `checkPositive([1, 2, 3, -4, 5])` should return `false`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-filter-method-to-extract-data-from-an-array.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-filter-method-to-extract-data-from-an-array.md index cf4b07d73df..4e7bd57545d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-filter-method-to-extract-data-from-an-array.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-filter-method-to-extract-data-from-an-array.md @@ -46,13 +46,13 @@ assert( Your code should use the `filter` method. ```js -assert(code.match(/\s*\.\s*filter/g)); +assert(__helpers.removeJSComments(code).match(/\s*\.\s*filter/g)); ``` Your code should not use a `for` loop. ```js -assert(!code.match(/for\s*?\([\s\S]*?\)/g)); +assert(!__helpers.removeJSComments(code).match(/for\s*?\([\s\S]*?\)/g)); ``` `filteredList` should equal `[{"title": "Inception", "rating": "8.8"}, {"title": "Interstellar", "rating": "8.6"}, {"title": "The Dark Knight", "rating": "9.0"}, {"title": "Batman Begins", "rating": "8.3"}]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array.md index d4eeaee7672..999779f850c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array.md @@ -52,13 +52,13 @@ assert( Your code should not use a `for` loop. ```js -assert(!code.match(/for\s*?\([\s\S]*?\)/)); +assert(!__helpers.removeJSComments(code).match(/for\s*?\([\s\S]*?\)/)); ``` Your code should use the `map` method. ```js -assert(code.match(/\.map/g)); +assert(__helpers.removeJSComments(code).match(/\.map/g)); ``` `ratings` should equal `[{"title": "Inception", "rating": "8.8"}, {"title": "Interstellar", "rating": "8.6"}, {"title": "The Dark Knight", "rating": "9.0"},{"title": "Batman Begins", "rating": "8.3"}, {"title": "Avatar", "rating": "7.9"}]`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-reduce-method-to-analyze-data.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-reduce-method-to-analyze-data.md index 6d3260b0d58..f9b9ef5797c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-reduce-method-to-analyze-data.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-reduce-method-to-analyze-data.md @@ -66,7 +66,7 @@ assert( Your code should use the `reduce` method. ```js -assert(code.match(/\.reduce/g)); +assert(__helpers.removeJSComments(code).match(/\.reduce/g)); ``` The `getRating(watchList)` should equal 8.675. @@ -78,7 +78,7 @@ assert(getRating(watchList) === 8.675); Your code should not use a `for` loop. ```js -assert(!code.match(/for\s*?\([\s\S]*?\)/g)); +assert(!__helpers.removeJSComments(code).match(/for\s*?\([\s\S]*?\)/g)); ``` Your code should return the correct output after modifying the `watchList` object. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-some-method-to-check-that-any-elements-in-an-array-meet-a-criteria.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-some-method-to-check-that-any-elements-in-an-array-meet-a-criteria.md index 9e949a9b4b0..393ed21d432 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-some-method-to-check-that-any-elements-in-an-array-meet-a-criteria.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-some-method-to-check-that-any-elements-in-an-array-meet-a-criteria.md @@ -31,7 +31,7 @@ Use the `some` method inside the `checkPositive` function to check if any elemen Your code should use the `some` method. ```js -assert(code.match(/\.some/g)); +assert(__helpers.removeJSComments(code).match(/\.some/g)); ``` `checkPositive([1, 2, 3, -4, 5])` should return `true`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md index e0538763619..e6e2f2ef50c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md @@ -39,7 +39,7 @@ assert.deepEqual(steamrollArray([1, {}, [3, [[4]]]]), [1, {}, 3, 4]); Your solution should not use the `Array.prototype.flat()` or `Array.prototype.flatMap()` methods. ```js -assert(!code.match(/\.\s*flat\s*\(/) && !code.match(/\.\s*flatMap\s*\(/)); +assert(!__helpers.removeJSComments(code).match(/\.\s*flat\s*\(/) && !__helpers.removeJSComments(code).match(/\.\s*flatMap\s*\(/)); ``` Global variables should not be used. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/change-the-prototype-to-a-new-object.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/change-the-prototype-to-a-new-object.md index 5313994f242..0fdd4c2bf41 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/change-the-prototype-to-a-new-object.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/change-the-prototype-to-a-new-object.md @@ -49,7 +49,7 @@ Add the property `numLegs` and the two methods `eat()` and `describe()` to the ` `Dog.prototype` should be set to a new object. ```js -assert(/Dog\.prototype\s*?=\s*?{/.test(code)); +assert(/Dog\.prototype\s*?=\s*?{/.test(__helpers.removeJSComments(code))); ``` `Dog.prototype` should have the property `numLegs`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/inherit-behaviors-from-a-supertype.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/inherit-behaviors-from-a-supertype.md index 27fa9f57b7c..07d1f417a7b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/inherit-behaviors-from-a-supertype.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/inherit-behaviors-from-a-supertype.md @@ -61,7 +61,7 @@ The `duck` variable should be initialised with `Object.create`. ```js assert( /(let|const|var)\s{1,}duck\s*=\s*Object\.create\s*\(\s*Animal\.prototype\s*\)\s*/.test( - code + __helpers.removeJSComments(code) ) ); ``` @@ -71,7 +71,7 @@ The `beagle` variable should be initialised with `Object.create`. ```js assert( /(let|const|var)\s{1,}beagle\s*=\s*Object\.create\s*\(\s*Animal\.prototype\s*\)\s*/.test( - code + __helpers.removeJSComments(code) ) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/iterate-over-all-properties.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/iterate-over-all-properties.md index 75444c77126..bad85d4905c 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/iterate-over-all-properties.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/iterate-over-all-properties.md @@ -61,7 +61,7 @@ assert.deepEqual(prototypeProps, ['numLegs']); You should solve this challenge without using the built in method `Object.keys()`. ```js -assert(!/\Object.keys/.test(code)); +assert(!/\Object.keys/.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/make-code-more-reusable-with-the-this-keyword.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/make-code-more-reusable-with-the-this-keyword.md index b0c80c8ee4c..d0c24b5c472 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/make-code-more-reusable-with-the-this-keyword.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/make-code-more-reusable-with-the-this-keyword.md @@ -43,7 +43,7 @@ assert(dog.sayLegs() === 'This dog has 4 legs.'); Your code should use the `this` keyword to access the `numLegs` property of `dog`. ```js -assert(code.match(/this\.numLegs/g)); +assert(__helpers.removeJSComments(code).match(/this\.numLegs/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-own-properties.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-own-properties.md index 2eb048692a7..4053289b262 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-own-properties.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-own-properties.md @@ -51,7 +51,7 @@ assert(ownProps.indexOf('name') !== -1 && ownProps.indexOf('numLegs') !== -1); You should solve this challenge without using the built in method `Object.keys()`. ```js -assert(!/Object(\.keys|\[(['"`])keys\2\])/.test(code)); +assert(!/Object(\.keys|\[(['"`])keys\2\])/.test(__helpers.removeJSComments(code))); ``` You should solve this challenge without hardcoding the `ownProps` array. @@ -59,7 +59,7 @@ You should solve this challenge without hardcoding the `ownProps` array. ```js assert( !/\[\s*(?:'|")(?:name|numLegs)|(?:push|concat)\(\s*(?:'|")(?:name|numLegs)/.test( - code + __helpers.removeJSComments(code) ) ); ``` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-constructor-property.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-constructor-property.md index 17b2bf83598..a3cd74fa7f5 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-constructor-property.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-constructor-property.md @@ -55,7 +55,7 @@ assert(joinDogFraternity(new Dog('')) === true); `joinDogFraternity` should use the `constructor` property. ```js -assert(/\.constructor/.test(code) && !/instanceof/.test(code)); +assert(/\.constructor/.test(__helpers.removeJSComments(code)) && !/instanceof/.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-immediately-invoked-function-expression-iife.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-immediately-invoked-function-expression-iife.md index 67ebe4d0e79..6692f8321f8 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-immediately-invoked-function-expression-iife.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-immediately-invoked-function-expression-iife.md @@ -29,13 +29,13 @@ Rewrite the function `makeNest` and remove its call so instead it's an anonymous The function should be anonymous. ```js -assert(/\((function|\(\))(=>|\(\)){?/.test(code.replace(/\s/g, ''))); +assert(/\((function|\(\))(=>|\(\)){?/.test(__helpers.removeJSComments(code).replace(/\s/g, ''))); ``` Your function should have parentheses at the end of the expression to call it immediately. ```js -assert(/\(.*(\)\(|\}\(\))\)/.test(code.replace(/[\s;]/g, ''))); +assert(/\(.*(\)\(|\}\(\))\)/.test(__helpers.removeJSComments(code).replace(/[\s;]/g, ''))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-prototype-chain.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-prototype-chain.md index 1ee203a745f..7cca4c8aa9f 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-prototype-chain.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-prototype-chain.md @@ -42,7 +42,7 @@ Modify the code to show the correct prototype chain. Your code should show that `Object.prototype` is the prototype of `Dog.prototype` ```js -assert(/Object\.prototype\.isPrototypeOf/.test(code)); +assert(/Object\.prototype\.isPrototypeOf/.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-where-an-objects-prototype-comes-from.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-where-an-objects-prototype-comes-from.md index ce7ed680ff0..4174c9b679e 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-where-an-objects-prototype-comes-from.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-where-an-objects-prototype-comes-from.md @@ -35,7 +35,7 @@ Use `isPrototypeOf` to check the `prototype` of `beagle`. You should show that `Dog.prototype` is the `prototype` of `beagle` ```js -assert(/Dog\.prototype\.isPrototypeOf\(beagle\)/.test(code)); +assert(/Dog\.prototype\.isPrototypeOf\(beagle\)/.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-a-constructor-to-create-objects.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-a-constructor-to-create-objects.md index 122fcb9a59b..60d7ba24dbe 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-a-constructor-to-create-objects.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-a-constructor-to-create-objects.md @@ -52,7 +52,7 @@ assert(hound instanceof Dog); Your code should use the `new` operator to create an instance of `Dog`. ```js -assert(code.match(/new/g)); +assert(__helpers.removeJSComments(code).match(/new/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-closure-to-protect-properties-within-an-object-from-being-modified-externally.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-closure-to-protect-properties-within-an-object-from-being-modified-externally.md index db936ea17d7..c487e5efd0f 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-closure-to-protect-properties-within-an-object-from-being-modified-externally.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-closure-to-protect-properties-within-an-object-from-being-modified-externally.md @@ -44,7 +44,7 @@ Change how `weight` is declared in the `Bird` function so it is a private variab The `weight` property should be a private variable and should be assigned the value of `15`. ```js -assert(code.match(/(var|let|const)\s+weight\s*\=\s*15\;?/g)); +assert(__helpers.removeJSComments(code).match(/(var|let|const)\s+weight\s*\=\s*15\;?/g)); ``` Your code should create a method in `Bird` called `getWeight` that returns the value of the private variable `weight`. @@ -56,7 +56,7 @@ assert(new Bird().getWeight() === 15); Your `getWeight` function should return the private variable `weight`. ```js -assert(code.match(/((return\s+)|(\(\s*\)\s*\=\>\s*))weight\;?/g)); +assert(__helpers.removeJSComments(code).match(/((return\s+)|(\(\s*\)\s*\=\>\s*))weight\;?/g)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-dot-notation-to-access-the-properties-of-an-object.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-dot-notation-to-access-the-properties-of-an-object.md index c2a6b1700b5..0811bdb7f7a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-dot-notation-to-access-the-properties-of-an-object.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-dot-notation-to-access-the-properties-of-an-object.md @@ -29,13 +29,13 @@ Print both properties of the `dog` object to your console. Your code should use `console.log` to print the value for the `name` property of the `dog` object. ```js -assert(/console.log\(.*dog\.name.*\)/g.test(code)); +assert(/console.log\(.*dog\.name.*\)/g.test(__helpers.removeJSComments(code))); ``` Your code should use `console.log` to print the value for the `numLegs` property of the `dog` object. ```js -assert(/console.log\(.*dog\.numLegs.*\)/g.test(code)); +assert(/console.log\(.*dog\.numLegs.*\)/g.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/verify-an-objects-constructor-with-instanceof.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/verify-an-objects-constructor-with-instanceof.md index 232e29ed517..02be676721b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/verify-an-objects-constructor-with-instanceof.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/verify-an-objects-constructor-with-instanceof.md @@ -53,7 +53,7 @@ assert(typeof myHouse.numBedrooms === 'number'); You should verify that `myHouse` is an instance of `House` using the `instanceof` operator. ```js -assert(/myHouse\s*instanceof\s*House/.test(code)); +assert(/myHouse\s*instanceof\s*House/.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-mixed-grouping-of-characters.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-mixed-grouping-of-characters.md index 54896bca102..3be5622cf5d 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-mixed-grouping-of-characters.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/check-for-mixed-grouping-of-characters.md @@ -75,7 +75,7 @@ assert(!myRegex.test('EleanorRoosevelt')); You should use `.test()` to test the regex. ```js -assert(code.match(/myRegex.test\(\s*myString\s*\)/)); +assert(__helpers.removeJSComments(code).match(/myRegex.test\(\s*myString\s*\)/)); ``` Your result should return `true`. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/extract-matches.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/extract-matches.md index 887f6e36293..09f7f637cda 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/extract-matches.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/extract-matches.md @@ -51,7 +51,7 @@ assert(codingRegex.source === 'coding'); You should use the `.match()` method. ```js -assert(code.match(/\.match\(.*\)/)); +assert(__helpers.removeJSComments(code).match(/\.match\(.*\)/)); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-anything-with-wildcard-period.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-anything-with-wildcard-period.md index 3306cfb8c76..0df9ec3ba3b 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-anything-with-wildcard-period.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-anything-with-wildcard-period.md @@ -31,7 +31,7 @@ Complete the regex `unRegex` so that it matches the strings `run`, `sun`, `fun`, You should use the `.test()` method. ```js -assert(code.match(/\.test\(.*\)/)); +assert(__helpers.removeJSComments(code).match(/\.test\(.*\)/)); ``` You should use the wildcard character in your regex `unRegex` diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-literal-strings.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-literal-strings.md index fdd712a81ff..edbaaaf5134 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-literal-strings.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-literal-strings.md @@ -52,7 +52,7 @@ assert(!waldoRegex.test('Somewhere is hiding in this text.')); You should perform a literal string match with your regex. ```js -assert(!/\/.*\/i/.test(code)); +assert(!/\/.*\/i/.test(__helpers.removeJSComments(code))); ``` # --seed-- diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/remove-whitespace-from-start-and-end.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/remove-whitespace-from-start-and-end.md index bb35ed6c031..7e6c1eb0a7a 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/remove-whitespace-from-start-and-end.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/remove-whitespace-from-start-and-end.md @@ -27,13 +27,13 @@ assert(result === 'Hello, World!'); Your solution should not use the `String.prototype.trim()` method. ```js -assert(!code.match(/\.?[\s\S]*?trim/)); +assert(!__helpers.removeJSComments(code).match(/\.?[\s\S]*?trim/)); ``` The `result` variable should not directly be set to a string ```js -assert(!code.match(/result\s*=\s*["'`].*?["'`]/)); +assert(!__helpers.removeJSComments(code).match(/result\s*=\s*["'`].*?["'`]/)); ``` The value of the `hello` variable should not be changed. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/use-capture-groups-to-search-and-replace.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/use-capture-groups-to-search-and-replace.md index 6b1d6b05924..e4b529c5eca 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/use-capture-groups-to-search-and-replace.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/use-capture-groups-to-search-and-replace.md @@ -37,7 +37,7 @@ Write a regex `fixRegex` using three capture groups that will search for each wo You should use `.replace()` to search and replace. ```js -assert(code.match(/\.replace\(.*\)/)); +assert(__helpers.removeJSComments(code).match(/\.replace\(.*\)/)); ``` Your regex should change the string `one two three` to the string `three two one` @@ -49,7 +49,7 @@ assert(result === 'three two one'); You should not change the last line. ```js -assert(code.match(/result\s*=\s*str\.replace\(.*?\)/)); +assert(__helpers.removeJSComments(code).match(/result\s*=\s*str\.replace\(.*?\)/)); ``` `fixRegex` should use at least three capture groups. diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/using-the-test-method.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/using-the-test-method.md index dddb321ec55..5a04d2617d9 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/using-the-test-method.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/using-the-test-method.md @@ -31,7 +31,7 @@ Apply the regex `myRegex` on the string `myString` using the `.test()` method. You should use `.test()` to test the regex. ```js -assert(code.match(/myRegex.test\(\s*myString\s*\)/)); +assert(__helpers.removeJSComments(code).match(/myRegex.test\(\s*myString\s*\)/)); ``` Your result should return `true`. diff --git a/curriculum/challenges/english/10-coding-interview-prep/data-structures/learn-how-a-stack-works.md b/curriculum/challenges/english/10-coding-interview-prep/data-structures/learn-how-a-stack-works.md index 19ea0d3c265..397f8d13d67 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/data-structures/learn-how-a-stack-works.md +++ b/curriculum/challenges/english/10-coding-interview-prep/data-structures/learn-how-a-stack-works.md @@ -48,9 +48,9 @@ The initial declaration of the `homeworkStack` should not be changed. ```js assert( - code.match(/=/g).length === 1 && + __helpers.removeJSComments(code).match(/=/g).length === 1 && /homeworkStack\s*=\s*\["BIO12"\s*,\s*"HIS80"\s*,\s*"MAT122"\s*,\s*"PSY44"\]/.test( - code + __helpers.removeJSComments(code) ) ); ``` diff --git a/curriculum/challenges/english/14-responsive-web-design-22/learn-basic-css-by-building-a-cafe-menu/5f356ed60a5decd94ab66986.md b/curriculum/challenges/english/14-responsive-web-design-22/learn-basic-css-by-building-a-cafe-menu/5f356ed60a5decd94ab66986.md index 82012ae3d4b..b4cce805660 100644 --- a/curriculum/challenges/english/14-responsive-web-design-22/learn-basic-css-by-building-a-cafe-menu/5f356ed60a5decd94ab66986.md +++ b/curriculum/challenges/english/14-responsive-web-design-22/learn-basic-css-by-building-a-cafe-menu/5f356ed60a5decd94ab66986.md @@ -2,7 +2,6 @@ id: 5f356ed60a5decd94ab66986 title: Step 22 challengeType: 0 -removeComments: false dashedName: step-22 --- diff --git a/curriculum/get-challenges.js b/curriculum/get-challenges.js index a0b2229b311..f4626a19b5a 100644 --- a/curriculum/get-challenges.js +++ b/curriculum/get-challenges.js @@ -299,10 +299,6 @@ function generateChallengeCreator(lang, englishPath, i18nPath) { // can sort them correctly. challenge.solutions = challenge.solutions.map(challengeFilesToPolys); } - // if removeComments is not explicitly set, default to true - if (typeof challenge.removeComments === 'undefined') { - challenge.removeComments = true; - } } async function createChallenge(filePath, maybeMeta) { diff --git a/curriculum/schema/__snapshots__/challenge-schema.test.js.snap b/curriculum/schema/__snapshots__/challenge-schema.test.js.snap index c9afa05dcca..267c56deba8 100644 --- a/curriculum/schema/__snapshots__/challenge-schema.test.js.snap +++ b/curriculum/schema/__snapshots__/challenge-schema.test.js.snap @@ -90,7 +90,6 @@ const schema = Joi.object() block: Joi.string().regex(slugRE).required(), blockId: Joi.objectId(), challengeOrder: Joi.number(), - removeComments: Joi.bool().required(), certification: Joi.string().regex(slugWithSlashRE), challengeType: Joi.number().min(0).max(23).required(), checksum: Joi.number(), diff --git a/curriculum/schema/challenge-schema.js b/curriculum/schema/challenge-schema.js index 332f2218d04..f873cfa1efb 100644 --- a/curriculum/schema/challenge-schema.js +++ b/curriculum/schema/challenge-schema.js @@ -87,7 +87,6 @@ const schema = Joi.object() block: Joi.string().regex(slugRE).required(), blockId: Joi.objectId(), challengeOrder: Joi.number(), - removeComments: Joi.bool().required(), certification: Joi.string().regex(slugWithSlashRE), challengeType: Joi.number().min(0).max(23).required(), checksum: Joi.number(), diff --git a/curriculum/test/test-challenges.js b/curriculum/test/test-challenges.js index 5f70bbec434..3658569e211 100644 --- a/curriculum/test/test-challenges.js +++ b/curriculum/test/test-challenges.js @@ -548,7 +548,7 @@ async function createTestRunner( buildChallenge, solutionFromNext ) { - const { required = [], template, removeComments } = challenge; + const { required = [], template } = challenge; const challengeFiles = replaceChallengeFilesContentsWithSolutions( challenge.challengeFiles, @@ -575,13 +575,7 @@ async function createTestRunner( const evaluator = await (runsInBrowser ? getContextEvaluator(build, sources, code, loadEnzyme) - : getWorkerEvaluator( - build, - sources, - code, - removeComments, - runsInPythonWorker - )); + : getWorkerEvaluator(build, sources, code, runsInPythonWorker)); return async ({ text, testString }) => { try { @@ -643,13 +637,7 @@ async function getContextEvaluator(build, sources, code, loadEnzyme) { }; } -async function getWorkerEvaluator( - build, - sources, - code, - removeComments, - runsInPythonWorker -) { +async function getWorkerEvaluator(build, sources, code, runsInPythonWorker) { // The python worker clears the globals between tests, so it should be fine // to use the same evaluator for all tests. TODO: check if this is true for // sys, since sys.modules is not being reset. @@ -658,10 +646,8 @@ async function getWorkerEvaluator( : new WorkerExecutor(javaScriptTestEvaluator, { terminateWorker: true }); return { evaluate: async (testString, timeout) => - await testWorker.execute( - { testString, build, code, sources, removeComments }, - timeout - ).done + await testWorker.execute({ testString, build, code, sources }, timeout) + .done }; } diff --git a/tools/client-plugins/browser-scripts/python-test-evaluator.ts b/tools/client-plugins/browser-scripts/python-test-evaluator.ts index 581ec218554..50fef2a9d1d 100644 --- a/tools/client-plugins/browser-scripts/python-test-evaluator.ts +++ b/tools/client-plugins/browser-scripts/python-test-evaluator.ts @@ -18,7 +18,6 @@ interface PythonRunEvent extends MessageEvent { editableContents: string; original: { [id: string]: string }; }; - removeComments: boolean; firstTest: unknown; testString: string; build: string; @@ -64,7 +63,6 @@ void setupPyodide(); ctx.onmessage = async (e: PythonRunEvent) => { const pyodide = await setupPyodide(); - // TODO: Use removeComments when we have it /* eslint-disable @typescript-eslint/no-unused-vars */ const code = (e.data.code.contents || '').slice(); const editableContents = (e.data.code.editableContents || '').slice(); diff --git a/tools/client-plugins/browser-scripts/test-evaluator.ts b/tools/client-plugins/browser-scripts/test-evaluator.ts index 3e26ac958da..f347bda7b70 100644 --- a/tools/client-plugins/browser-scripts/test-evaluator.ts +++ b/tools/client-plugins/browser-scripts/test-evaluator.ts @@ -87,7 +87,6 @@ interface TestEvaluatorEvent extends MessageEvent { editableContents: string; original: { [id: string]: string }; }; - removeComments: boolean; firstTest: unknown; testString: string; build: string; @@ -100,12 +99,8 @@ interface TestEvaluatorEvent extends MessageEvent { /* Run the test if there is one. If not just evaluate the user code */ ctx.onmessage = async (e: TestEvaluatorEvent) => { /* eslint-disable @typescript-eslint/no-unused-vars */ - let code = (e.data?.code?.contents || '').slice(); - code = e.data?.removeComments ? helpers.removeJSComments(code) : code; - let editableContents = (e.data?.code?.editableContents || '').slice(); - editableContents = e.data?.removeComments - ? helpers.removeJSComments(editableContents) - : editableContents; + const code = (e.data?.code?.contents || '').slice(); + const editableContents = (e.data?.code?.editableContents || '').slice(); const assert = chai.assert; const __helpers = helpers; @@ -129,11 +124,7 @@ ctx.onmessage = async (e: TestEvaluatorEvent) => { try { // Logging is proxyed after the build to catch console.log messages // generated during testing. - testResult = (await eval(`${ - e.data?.removeComments - ? helpers.removeJSComments(e.data.build) - : e.data.build - } + testResult = (await eval(`${e.data.build} __utils.flushLogs(); __userCodeWasExecuted = true; __utils.toggleProxyLogger(true);