chore(i18n,learn): processed translations (#54537)

Co-authored-by: Naomi <nhcarrigan@gmail.com>
This commit is contained in:
freeCodeCamp's Camper Bot
2024-04-26 10:56:37 +05:30
committed by GitHub
parent adfb87e898
commit e6b05ee25d
2107 changed files with 8339 additions and 3516 deletions

View File

@@ -54,7 +54,7 @@ assert(
```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;

View File

@@ -45,7 +45,7 @@ assert(myData === 8);
你应该使用方括号从 `myArray` 中读取正确的值。
```js
assert(/myData=myArray\[2\]\[1\]/.test(__helpers.removeWhiteSpace(code)));
assert(/myData=myArray\[2\]\[1\]/.test(__helpers.removeWhiteSpace(__helpers.removeJSComments(code))));
```
# --seed--

View File

@@ -54,7 +54,7 @@ assert(secondTree === 'pine');
你的代码应该使用点号和方括号访问 `myPlants`
```js
assert(/=\s*myPlants\[1\].list\[1\]/.test(code));
assert(/=\s*myPlants\[1\].list\[1\]/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -64,7 +64,7 @@ assert(drinkValue === 'water');
你应该使用两次方括号
```js
assert(code.match(/testObj\s*?\[('|")[^'"]+\1\]/g).length > 1);
assert(__helpers.removeJSComments(code).match(/testObj\s*?\[('|")[^'"]+\1\]/g).length > 1);
```
# --seed--

View File

@@ -60,7 +60,7 @@ assert(shirtValue === 'jersey');
你应该使用两个点号
```js
assert(code.match(/testObj\.\w+/g).length > 1);
assert(__helpers.removeJSComments(code).match(/testObj\.\w+/g).length > 1);
```
# --seed--

View File

@@ -56,19 +56,19 @@ assert(player === 'Montana');
你应该使用括号表示法来访问 `testObj`
```js
assert(/testObj\s*?\[.*?\]/.test(code));
assert(/testObj\s*?\[.*?\]/.test(__helpers.removeJSComments(code)));
```
你不应将值 `Montana` 直接分配给变量 `player`
```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));
```
你应该在括号符号中使用变量 `playerNumber`
```js
assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code));
assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -53,7 +53,7 @@ assert(myDog.bark !== undefined);
不应该在 `myDog` 的初始化中添加 `bark`
```js
assert(!/bark[^\n]:/.test(code));
assert(!/bark[^\n]:/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -38,7 +38,7 @@ assert(sum === 20);
请使用 `+` 运算符。
```js
assert(/\+/.test(code));
assert(/\+/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -71,7 +71,7 @@ assert(switchOfStuff(4) === 'stuff');
不能使用 `if``else` 语句。
```js
assert(!/else/g.test(code) || !/if/g.test(code));
assert(!/else/g.test(__helpers.removeJSComments(code)) || !/if/g.test(__helpers.removeJSComments(code)));
```
你应该使用 `default` 语句。
@@ -83,7 +83,7 @@ assert(switchOfStuff('string-to-trigger-default-case') === 'stuff');
你至少应该写 3 个 `break` 语句。
```js
assert(code.match(/break/g).length > 2);
assert(__helpers.removeJSComments(code).match(/break/g).length > 2);
```
# --seed--

View File

@@ -36,7 +36,7 @@ assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);
你应该使用 `+=` 运算符将 `someAdjective` 追加到 `myStr`
```js
assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
assert(__helpers.removeJSComments(code).match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
```
# --seed--

View File

@@ -29,7 +29,7 @@ myNum = myVar;
你不应该修改注释上面的代码。
```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` 的值应该为 `7`
@@ -41,7 +41,7 @@ assert(typeof b === 'number' && b === 7);
应该使用 `=``a` 赋给 `b`
```js
assert(/b\s*=\s*a\s*/g.test(code));
assert(/b\s*=\s*a\s*/g.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -34,7 +34,7 @@ assert(processed === 2);
应该将 `processArg` 赋值给 `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--

View File

@@ -39,19 +39,19 @@ if (condition1) {
应至少有 4 个 `else` 语句。
```js
assert(code.match(/else/g).length > 3);
assert(__helpers.removeJSComments(code).match(/else/g).length > 3);
```
应至少有 4 个 `if` 语句。
```js
assert(code.match(/if/g).length > 3);
assert(__helpers.removeJSComments(code).match(/if/g).length > 3);
```
应至少有 1 个 `return` 语句。
```js
assert(code.match(/return/g).length >= 1);
assert(__helpers.removeJSComments(code).match(/return/g).length >= 1);
```
`testSize(0)` 应该返回字符串 `Tiny`

View File

@@ -2,7 +2,6 @@
id: bd7123c9c441eddfaeb4bdef
title: 给代码添加注释
challengeType: 1
removeComments: false
videoUrl: 'https://scrimba.com/c/c7ynnTp'
forumTopicId: 16783
dashedName: comment-your-javascript-code

View File

@@ -58,7 +58,7 @@ assert(testEqual('12') === 'Equal');
应该使用 `==` 运算符
```js
assert(code.match(/==/g) && !code.match(/===/g));
assert(__helpers.removeJSComments(code).match(/==/g) && !__helpers.removeJSComments(code).match(/===/g));
```
# --seed--

View File

@@ -73,7 +73,7 @@ assert(testGreaterThan(150) === 'Over 100');
你应该使用 `>` 至少两次
```js
assert(code.match(/val\s*>\s*('|")*\d+('|")*/g).length > 1);
assert(__helpers.removeJSComments(code).match(/val\s*>\s*('|")*\d+('|")*/g).length > 1);
```
# --seed--

View File

@@ -73,7 +73,7 @@ assert(testGreaterOrEqual(21) === '20 or Over');
你应该使用 `>=` 运算符至少两次。
```js
assert(code.match(/val\s*>=\s*('|")*\d+('|")*/g).length > 1);
assert(__helpers.removeJSComments(code).match(/val\s*>=\s*('|")*\d+('|")*/g).length > 1);
```
# --seed--

View File

@@ -60,7 +60,7 @@ assert(testNotEqual('bob') === 'Not Equal');
你应该使用 `!=` 运算符
```js
assert(code.match(/(?!!==)!=/));
assert(__helpers.removeJSComments(code).match(/(?!!==)!=/));
```
# --seed--

View File

@@ -66,7 +66,7 @@ assert(testLessThan(99) === '55 or Over');
应该使用 `<` 运算符至少两次
```js
assert(code.match(/val\s*<\s*('|")*\d+('|")*/g).length > 1);
assert(__helpers.removeJSComments(code).match(/val\s*<\s*('|")*\d+('|")*/g).length > 1);
```
# --seed--

View File

@@ -72,7 +72,7 @@ assert(testLessOrEqual(55) === 'More Than 24');
应该使用 `<=` 运算符至少两次
```js
assert(code.match(/val\s*<=\s*('|")*\d+('|")*/g).length > 1);
assert(__helpers.removeJSComments(code).match(/val\s*<=\s*('|")*\d+('|")*/g).length > 1);
```
# --seed--

View File

@@ -49,7 +49,7 @@ assert(testStrict('7') === 'Not Equal');
应该使用 `===` 运算符
```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--

View File

@@ -52,7 +52,7 @@ assert(testStrictNotEqual('bob') === 'Not Equal');
应该使用 `!==` 运算符
```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--

View File

@@ -40,13 +40,13 @@ return "No";
你应该使用 `&&` 运算符一次。
```js
assert(code.match(/&&/g).length === 1);
assert(__helpers.removeJSComments(code).match(/&&/g).length === 1);
```
你应该只有一个 `if` 表达式。
```js
assert(code.match(/if/g).length === 1);
assert(__helpers.removeJSComments(code).match(/if/g).length === 1);
```
`testLogicalAnd(0)` 应该返回字符串 `No`

View File

@@ -43,13 +43,13 @@ return "Yes";
应该使用一次 `||` 操作符。
```js
assert(code.match(/\|\|/g).length === 1);
assert(__helpers.removeJSComments(code).match(/\|\|/g).length === 1);
```
应该只有一个 `if` 表达式。
```js
assert(code.match(/if/g).length === 1);
assert(__helpers.removeJSComments(code).match(/if/g).length === 1);
```
`testLogicalOr(0)` 应该返回字符串 `Outside`

View File

@@ -54,16 +54,16 @@ assert(c === 19);
应该对每个变量使用 `+=` 操作符。
```js
assert(code.match(/\+=/g).length === 3);
assert(__helpers.removeJSComments(code).match(/\+=/g).length === 3);
```
不要修改注释上面的代码。
```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))
);
```

View File

@@ -48,16 +48,16 @@ assert(c === 3);
应该对每个变量使用 `/=` 操作符。
```js
assert(code.match(/\/=/g).length === 3);
assert(__helpers.removeJSComments(code).match(/\/=/g).length === 3);
```
不要修改注释上面的代码。
```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))
);
```

View File

@@ -48,16 +48,16 @@ assert(c === 46);
应该对每个变量使用 `*=` 操作符。
```js
assert(code.match(/\*=/g).length === 3);
assert(__helpers.removeJSComments(code).match(/\*=/g).length === 3);
```
不要修改注释上面的代码。
```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))
);
```

View File

@@ -48,14 +48,14 @@ assert(c === 2);
应该对每个变量使用 `-=` 操作符。
```js
assert(code.match(/-=/g).length === 3);
assert(__helpers.removeJSComments(code).match(/-=/g).length === 3);
```
不要修改注释上面的代码。
```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))
);
```

View File

@@ -47,19 +47,19 @@ assert(myStr === 'This is the start. This is the end.');
应该使用 `+` 运算符来构建 `myStr`
```js
assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));
assert(__helpers.removeJSComments(code).match(/(["']).*\1\s*\+\s*(["']).*\2/g));
```
`myStr` 应该使用 `const` 关键字创建。
```js
assert(/const\s+myStr/.test(code));
assert(/const\s+myStr/.test(__helpers.removeJSComments(code)));
```
应该将结果分配给 `myStr` 变量。
```js
assert(/myStr\s*=/.test(code));
assert(/myStr\s*=/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -43,7 +43,7 @@ assert(myStr === 'This is the first sentence. This is the second sentence.');
应该使用 `+=` 操作符创建 `myStr` 变量。
```js
assert(code.match(/myStr\s*\+=\s*(["']).*\1/g));
assert(__helpers.removeJSComments(code).match(/myStr\s*\+=\s*(["']).*\1/g));
```
# --seed--

View File

@@ -35,7 +35,7 @@ assert(typeof myName !== 'undefined' && myName.length > 2);
使用两个 `+` 操作符创建包含 `myName``myStr` 变量。
```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--

View File

@@ -34,13 +34,13 @@ for (let i = 10; i > 0; i -= 2) {
应该使用 `for` 循环。
```js
assert(/for\s*\([^)]+?\)/.test(code));
assert(/for\s*\([^)]+?\)/.test(__helpers.removeJSComments(code)));
```
应该使用数组方法 `push`
```js
assert(code.match(/myArray.push/));
assert(__helpers.removeJSComments(code).match(/myArray.push/));
```
`myArray` 应该等于 `[9, 7, 5, 3, 1]`

View File

@@ -37,7 +37,7 @@ var ourName;
使用 `var` 关键字定义一个变量 `myName`,并使用分号结尾。
```js
assert(/var\s+myName\s*;/.test(code));
assert(/var\s+myName\s*;/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -38,25 +38,25 @@ assert(myVar === 10);
应该修改 `myVar = myVar - 1;`
```js
assert(!code.match(/myVar\s*=\s*myVar\s*[-]\s*1.*?;?/));
assert(!__helpers.removeJSComments(code).match(/myVar\s*=\s*myVar\s*[-]\s*1.*?;?/));
```
你不应将 `10` 分配给 `myVar`
```js
assert(!code.match(/myVar\s*=\s*10.*?;?/));
assert(!__helpers.removeJSComments(code).match(/myVar\s*=\s*10.*?;?/));
```
应该对 `myVar` 使用 `--` 运算符。
```js
assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code));
assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(__helpers.removeJSComments(code)));
```
你不应该修改注释上面的代码。
```js
assert(/let myVar = 11;/.test(code));
assert(/let myVar = 11;/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -55,7 +55,7 @@ assert(typeof myDog === 'object' && myDog.tails === undefined);
不要修改 `myDog` 的初始化代码。
```js
assert(code.match(/"tails": 1/g).length > 0);
assert(__helpers.removeJSComments(code).match(/"tails": 1/g).length > 0);
```
# --seed--

View File

@@ -26,13 +26,13 @@ assert(quotient === 2.2);
使用 `/` 运算符将 4.4 除以 2。
```js
assert(/4\.40*\s*\/\s*2\.*0*/.test(code));
assert(/4\.40*\s*\/\s*2\.*0*/.test(__helpers.removeJSComments(code)));
```
quotient 变量应该只被赋值一次。
```js
assert(code.match(/quotient\s*=/g).length === 1);
assert(__helpers.removeJSComments(code).match(/quotient\s*=/g).length === 1);
```
# --seed--

View File

@@ -35,7 +35,7 @@ assert(quotient === 2);
使用 `/` 运算符。
```js
assert(/\d+\s*\/\s*\d+/.test(code));
assert(/\d+\s*\/\s*\d+/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -36,7 +36,7 @@ I am a "double quoted" string inside "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);
```
变量 `myStr` 应该包含字符串 `I am a "double quoted" string inside "double quotes".`

View File

@@ -29,8 +29,8 @@ console.log("Alan Peter".length);
```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);
你应该使用 `.length` 获取 `lastName` 的长度,像这样 `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--

View File

@@ -39,7 +39,7 @@ dashedName: finding-a-remainder-in-javascript
变量 `remainder` 应该被初始化。
```js
assert(/(const|let|var)\s+?remainder/.test(code));
assert(/(const|let|var)\s+?remainder/.test(__helpers.removeJSComments(code)));
```
`remainder` 的值应该等于 `2`
@@ -51,7 +51,7 @@ assert(remainder === 2);
你应该使用 `%` 运算符。
```js
assert(/\s+?remainder\s*?=\s*?.*%.*;?/.test(code));
assert(/\s+?remainder\s*?=\s*?.*%.*;?/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -36,7 +36,7 @@ assert((randomFraction() + '').match(/\./g));
需要使用 `Math.random` 生成随机的小数。
```js
assert(code.match(/Math\.random/g).length >= 0);
assert(__helpers.removeJSComments(code).match(/Math\.random/g).length >= 0);
```
# --seed--

View File

@@ -46,22 +46,22 @@ assert(
应该使用 `Math.random` 生成一个随机数字。
```js
assert(code.match(/Math.random/g).length >= 1);
assert(__helpers.removeJSComments(code).match(/Math.random/g).length >= 1);
```
应该将 `Math.random` 的结果乘以 10以生成 0 到 9 之间的随机数。
```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)
);
```
应该使用 `Math.floor` 来删除数字的十进制部分。
```js
assert(code.match(/Math.floor/g).length >= 1);
assert(__helpers.removeJSComments(code).match(/Math.floor/g).length >= 1);
```
# --seed--

View File

@@ -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 {

View File

@@ -36,7 +36,7 @@ assert(myGlobal === 10);
`myGlobal` 应该使用 `let``const` 关键字声明
```js
assert(/(let|const)\s+myGlobal/.test(code));
assert(/(let|const)\s+myGlobal/.test(__helpers.removeJSComments(code)));
```
`oopsGlobal` 应为全局变量,值为 `5`

View File

@@ -45,7 +45,7 @@ assert(myOutfit() === 'sweater');
不要修改 return 语句。
```js
assert(/return outerWear/.test(code));
assert(/return outerWear/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -39,20 +39,20 @@ assert(myVar === 88);
```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))
);
```
应该使用 `++` 运算符。
```js
assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code));
assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(__helpers.removeJSComments(code)));
```
不应该修改注释上面的代码。
```js
assert(/let myVar = 87;/.test(code));
assert(/let myVar = 87;/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -26,7 +26,7 @@ var myVar = 0;
应该初始化 `a` 的值为 `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--

View File

@@ -30,20 +30,20 @@ if (num > 15) {
你应该至少有两个 `else` 表达式。
```js
assert(code.match(/else/g).length > 1);
assert(__helpers.removeJSComments(code).match(/else/g).length > 1);
```
你应该至少有两个 `if` 表达式。
```js
assert(code.match(/if/g).length > 1);
assert(__helpers.removeJSComments(code).match(/if/g).length > 1);
```
应该关闭每一个 `if else` 代码块。
```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*\}/
)
);

View File

@@ -28,13 +28,13 @@ if (num > 10) {
应该只有一个 `if` 语句。
```js
assert(code.match(/if/g).length === 1);
assert(__helpers.removeJSComments(code).match(/if/g).length === 1);
```
应该使用一个 `else` 语句。
```js
assert(/else/g.test(code));
assert(/else/g.test(__helpers.removeJSComments(code)));
```
`testElse(4)` 应该返回字符串 `5 or Smaller`
@@ -64,7 +64,7 @@ assert(testElse(10) === 'Bigger than 5');
不要修改相应注释的上面或下面的代码。
```js
assert(/let result = "";/.test(code) && /return result;/.test(code));
assert(/let result = "";/.test(__helpers.removeJSComments(code)) && /return result;/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -32,7 +32,7 @@ for (let i = 0; i < 10; i += 2) {
应该使用 `for` 循环。
```js
assert(/for\s*\([^)]+?\)/.test(code));
assert(/for\s*\([^)]+?\)/.test(__helpers.removeJSComments(code)));
```
`myArray` 应该等于 `[1, 3, 5, 7, 9]`

View File

@@ -30,7 +30,7 @@ for (let i = 0; i < arr.length; i++) {
`total` 应该被声明, 并且初始化值为 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` 应该等于 20。
@@ -42,13 +42,13 @@ assert(total === 20);
你应该使用 `for` 循环在 `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)));
```
不能直接把 `total` 设置成 20。
```js
assert(!__helpers.removeWhiteSpace(code).match(/total[=+-]0*[1-9]+/gm));
assert(!__helpers.removeWhiteSpace(__helpers.removeJSComments(code)).match(/total[=+-]0*[1-9]+/gm));
```
# --seed--

View File

@@ -56,7 +56,7 @@ do {
你应该使用 `do...while` 循环。
```js
assert(code.match(/do/g));
assert(__helpers.removeJSComments(code).match(/do/g));
```
`myArray` 应该等于 `[10]`

View File

@@ -44,7 +44,7 @@ for (let i = 0; i < 5; i++) {
你应该使用 `for` 循环。
```js
assert(/for\s*\([^)]+?\)/.test(code));
assert(/for\s*\([^)]+?\)/.test(__helpers.removeJSComments(code)));
```
`myArray` 应该等于 `[1, 2, 3, 4, 5]`

View File

@@ -36,7 +36,7 @@ while (i < 5) {
你应该使用 `while` 循环。
```js
assert(code.match(/while/g));
assert(__helpers.removeJSComments(code).match(/while/g));
```
`myArray` 应该等于 `[5, 4, 3, 2, 1, 0]`

View File

@@ -48,7 +48,7 @@ assert.throws(declared, ReferenceError);
```js
assert(
/functionmyLocalScope\(\)\{.*(var|let|const)myVar[\s\S]*}/.test(
__helpers.removeWhiteSpace(code)
__helpers.removeWhiteSpace(__helpers.removeJSComments(code))
)
);
```

View File

@@ -47,7 +47,7 @@ assert(
`myArray` 使用 `pop()` 函数。
```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` 应该只包含 `["cat", 2]`

View File

@@ -52,7 +52,7 @@ assert(
```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;

View File

@@ -94,13 +94,13 @@ assert(sequentialSizes(9) === 'High');
你不应使用 `if``else` 语句。
```js
assert(!/else/g.test(code) || !/if/g.test(code));
assert(!/else/g.test(__helpers.removeJSComments(code)) || !/if/g.test(__helpers.removeJSComments(code)));
```
你应该编写 9 个`case`语句。
```js
assert(code.match(/case/g).length === 9);
assert(__helpers.removeJSComments(code).match(/case/g).length === 9);
```
# --seed--

View File

@@ -28,7 +28,7 @@ assert(product === 5.0);
要使用 `*` 运算符。
```js
assert(/\*/.test(code));
assert(/\*/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -36,7 +36,7 @@ assert(product === 80);
使用 `*` 运算符。
```js
assert(/\*/.test(code));
assert(/\*/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -60,7 +60,7 @@ assert(logOutput == 16);
```js
assert(
/functionWithArgs\([-+]?\d*\.?\d*,[-+]?\d*\.?\d*\)/.test(
code.replace(/\s/g, '')
__helpers.removeJSComments(code).replace(/\s/g, '')
)
);
```

View File

@@ -47,7 +47,7 @@ assert(compareEquality('20', 20) === 'Not Equal');
你应该使用 `===` 运算符
```js
assert(code.match(/===/g));
assert(__helpers.removeJSComments(code).match(/===/g));
```
# --seed--

View File

@@ -47,7 +47,7 @@ const badStr = 'Finn responds, "Let's go!"';
```js
assert(
!/\\/g.test(code) &&
!/\\/g.test(__helpers.removeJSComments(code)) &&
myStr.match(
'\\s*<a href\\s*=\\s*"http://www.example.com"\\s*target\\s*=\\s*"_blank">\\s*Link\\s*</a>\\s*'
)
@@ -57,7 +57,7 @@ assert(
应该要有两个单引号 `'` 和四个双引号 `"`
```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--

View File

@@ -66,7 +66,7 @@ assert.equal(sum([2, 3, 4, 5], 3), 9);
```js
assert(
!code.match(/for|while|forEach|map|filter|reduce/g)
!__helpers.removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g)
);
```

View File

@@ -45,19 +45,19 @@ switch (val) {
不要使用 `else` 表达式
```js
assert(!/else/g.test(code));
assert(!/else/g.test(__helpers.removeJSComments(code)));
```
不要使用 `if` 表达式
```js
assert(!/if/g.test(code));
assert(!/if/g.test(__helpers.removeJSComments(code)));
```
你应该有至少 4 个 `break` 表达式
```js
assert(code.match(/break/g).length >= 4);
assert(__helpers.removeJSComments(code).match(/break/g).length >= 4);
```
`chainToSwitch("bob")` 应该返回字符串 `Marley`

View File

@@ -52,7 +52,7 @@ assert(isLess(15, 10) === false);
不应该使用 `if` 或者 `else` 语句
```js
assert(!/if|else/g.test(code));
assert(!/if|else/g.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -63,13 +63,13 @@ assert(caseInSwitch(4) === 'delta');
不能使用任何 `if``else` 表达式
```js
assert(!/else/g.test(code) || !/if/g.test(code));
assert(!/else/g.test(__helpers.removeJSComments(code)) || !/if/g.test(__helpers.removeJSComments(code)));
```
你应该有至少 3 个 `break` 表达式
```js
assert(code.match(/break/g).length > 2);
assert(__helpers.removeJSComments(code).match(/break/g).length > 2);
```
# --seed--

View File

@@ -35,7 +35,7 @@ myVar = 5;
不应该修改注释上面的代码。
```js
assert(/var a;/.test(code));
assert(/var a;/.test(__helpers.removeJSComments(code)));
```
`a` 的值应该为 7。

View File

@@ -35,7 +35,7 @@ assert(difference === 12);
你只能从 `45` 中减去一个数。
```js
assert(/difference=45-33;?/.test(__helpers.removeWhiteSpace(code)));
assert(/difference=45-33;?/.test(__helpers.removeWhiteSpace(__helpers.removeJSComments(code))));
```
# --seed--

View File

@@ -40,7 +40,7 @@ assert(myStr === 'Hello World');
不要修改注释上面的代码。
```js
assert(/myStr = "Jello World"/.test(code));
assert(/myStr = "Jello World"/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -56,19 +56,19 @@ assert(typeof titleCaseOver !== 'undefined' && titleCaseOver === 9000);
`studlyCapVar` 在声明和赋值时都应该使用驼峰命名法。
```js
assert(code.match(/studlyCapVar/g).length === 2);
assert(__helpers.removeJSComments(code).match(/studlyCapVar/g).length === 2);
```
`properCamelCase` 在声明和赋值时都应该使用驼峰命名法。
```js
assert(code.match(/properCamelCase/g).length === 2);
assert(__helpers.removeJSComments(code).match(/properCamelCase/g).length === 2);
```
`titleCaseOver` 在声明和赋值时都应该使用驼峰命名法。
```js
assert(code.match(/titleCaseOver/g).length === 2);
assert(__helpers.removeJSComments(code).match(/titleCaseOver/g).length === 2);
```
# --seed--

View File

@@ -39,9 +39,9 @@ assert(!/undefined/.test(c) && c === 'I am a String!');
```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))
);
```

View File

@@ -39,7 +39,7 @@ assert(/happy coder/gi.test(myDog.name));
不要修改 `myDog` 的定义。
```js
assert(/"name": "Coder"/.test(code));
assert(/"name": "Coder"/.test(__helpers.removeJSComments(code)));
```
# --seed--

View File

@@ -41,7 +41,7 @@ assert(firstLetterOfLastName === 'L');
应该使用方括号表示法。
```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--

View File

@@ -39,7 +39,7 @@ assert(lastLetterOfLastName === 'e');
您应该使用 `.length` 获取最后一个字母。
```js
assert(code.match(/\.length/g).length > 0);
assert(__helpers.removeJSComments(code).match(/\.length/g).length > 0);
```
# --seed--

View File

@@ -39,7 +39,7 @@ assert(thirdLetterOfLastName === 'v');
应该使用方括号表示法。
```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--

View File

@@ -39,7 +39,7 @@ assert(secondToLastLetterOfLastName === 'c');
您应该使用 `.length` 获取倒数第二个字母。
```js
assert(code.match(/\.length/g).length > 0);
assert(__helpers.removeJSComments(code).match(/\.length/g).length > 0);
```
# --seed--

View File

@@ -54,7 +54,7 @@ function findGreaterOrEqual(a, b) {
`checkSign` 应该使用多个三元运算符。
```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)` 应该返回字符串 `positive`。 注意区分大写字母和小写字母。

View File

@@ -59,7 +59,7 @@ assert.deepStrictEqual(countdown(5), [5, 4, 3, 2, 1]);
```js
assert(
!code.match(/for|while|forEach|map|filter|reduce/g)
!__helpers.removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g)
);
```

View File

@@ -26,7 +26,7 @@ assert(Array.isArray(rangeOfNumbers(5, 10)));
```js
assert(
!code.match(/for|while|forEach|map|filter|reduce/g)
!__helpers.removeJSComments(code).match(/for|while|forEach|map|filter|reduce/g)
);
```

View File

@@ -42,7 +42,7 @@ function findGreater(a, b) {
`checkEqual` 应该使用条件运算符。
```js
assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?/.test(code));
assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?/.test(__helpers.removeJSComments(code)));
```
`checkEqual(1, 2)` 应该返回字符串 `Not Equal`

View File

@@ -34,7 +34,7 @@ const a = parseInt("11", 2);
`convertToInteger` 应该使用 `parseInt()` 函数。
```js
assert(/parseInt/g.test(code));
assert(/parseInt/g.test(__helpers.removeJSComments(code)));
```
`convertToInteger("10011")` 应该返回一个数字。

View File

@@ -26,7 +26,7 @@ const a = parseInt("007");
`convertToInteger` 中应该使用 `parseInt()` 函数。
```js
assert(/parseInt/g.test(code));
assert(/parseInt/g.test(__helpers.removeJSComments(code)));
```
`convertToInteger("56")` 应该返回一个数字。

View File

@@ -83,14 +83,14 @@ assert(typeof phoneticLookup('') === 'undefined');
请不要修改 `return` 语句
```js
assert(code.match(/return\sresult;/));
assert(__helpers.removeJSComments(code).match(/return\sresult;/));
```
请不要使用 `case``switch``if` 语句
```js
assert(
!/case|switch|if/g.test(code.replace(/([/]{2}.*)|([/][*][^/*]*[*][/])/g, ''))
!/case|switch|if/g.test(__helpers.removeJSComments(code).replace(/([/]{2}.*)|([/][*][^/*]*[*][/])/g, ''))
);
```

View File

@@ -53,7 +53,7 @@ assert(
你不应该直接使用 `dog``ran``big``quickly` 来创建 `wordBlanks`
```js
const newCode = removeAssignments(code);
const newCode = removeAssignments(__helpers.removeJSComments(code));
assert(
!/dog/.test(newCode) &&
!/ran/.test(newCode) &&

View File

@@ -50,7 +50,7 @@ assert(testConsole());
```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));
```