feat(curriculum): restore seed + solution to Chinese (#40683)

* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
This commit is contained in:
Oliver Eyton-Williams
2021-01-13 03:31:00 +01:00
committed by GitHub
parent 0095583028
commit ee1e8abd87
4163 changed files with 57505 additions and 10540 deletions

View File

@ -3,6 +3,7 @@ id: 587d7b85367417b2b2512b3a
title: 调用函数时,捕获以错误顺序传递的参数
challengeType: 1
forumTopicId: 301184
dashedName: catch-arguments-passed-in-the-wrong-order-when-calling-a-function
---
# --description--
@ -27,5 +28,30 @@ assert(power == 8);
assert(code.match(/raiseToPower\(\s*?base\s*?,\s*?exp\s*?\);/g));
```
# --seed--
## --seed-contents--
```js
function raiseToPower(b, e) {
return Math.pow(b, e);
}
let base = 2;
let exp = 3;
let power = raiseToPower(exp, base);
console.log(power);
```
# --solutions--
```js
function raiseToPower(b, e) {
return Math.pow(b, e);
}
let base = 2;
let exp = 3;
let power = raiseToPower(base, exp);
console.log(power);
```

View File

@ -3,6 +3,7 @@ id: 587d7b85367417b2b2512b39
title: 捕捉函数调用后缺少的左括号和右括号
challengeType: 1
forumTopicId: 301185
dashedName: catch-missing-open-and-closing-parenthesis-after-a-function-call
---
# --description--
@ -37,5 +38,30 @@ assert(result == 9);
assert(code.match(/getNine\(\)/g).length == 2);
```
# --seed--
## --seed-contents--
```js
function getNine() {
let x = 6;
let y = 3;
return x + y;
}
let result = getNine;
console.log(result);
```
# --solutions--
```js
function getNine() {
let x = 6;
let y = 3;
return x + y;
}
let result = getNine();
console.log(result);
```

View File

@ -3,6 +3,7 @@ id: 587d7b84367417b2b2512b35
title: 捕获拼错的变量名和函数名
challengeType: 1
forumTopicId: 301186
dashedName: catch-misspelled-variable-and-function-names
---
# --description--
@ -47,5 +48,22 @@ assert(!code.match(/payable;/g));
assert(code.match(/payables/g).length == 2);
```
# --seed--
## --seed-contents--
```js
let receivables = 10;
let payables = 8;
let netWorkingCapital = recievables - payable;
console.log(`Net working capital is: ${netWorkingCapital}`);
```
# --solutions--
```js
let receivables = 10;
let payables = 8;
let netWorkingCapital = receivables - payables;
console.log(`Net working capital is: ${netWorkingCapital}`);
```

View File

@ -3,6 +3,7 @@ id: 587d7b84367417b2b2512b37
title: 捕捉单引号和双引号的混合用法
challengeType: 1
forumTopicId: 301188
dashedName: catch-mixed-usage-of-single-and-double-quotes
---
# --description--
@ -46,5 +47,18 @@ assert(code.match(/<a href=\s*?('|\\")#Home\1\s*?>/g));
assert(code.match(/"<p>.*?<\/p>";/g));
```
# --seed--
## --seed-contents--
```js
let innerHtml = "<p>Click here to <a href="#Home">return home</a></p>";
console.log(innerHtml);
```
# --solutions--
```js
let innerHtml = "<p>Click here to <a href=\"#Home\">return home</a></p>";
console.log(innerHtml);
```

View File

@ -3,6 +3,7 @@ id: 587d7b86367417b2b2512b3b
title: 捕获使用索引的时候出现的错误
challengeType: 1
forumTopicId: 301189
dashedName: catch-off-by-one-errors-when-using-indexing
---
# --description--
@ -58,5 +59,36 @@ assert(code.match(/i\s*?<\s*?len\s*?;/g).length == 1);
assert(!code.match(/i\s*?<=\s*?len;/g));
```
# --seed--
## --seed-contents--
```js
function countToFive() {
let firstFive = "12345";
let len = firstFive.length;
// Only change code below this line
for (let i = 1; i <= len; i++) {
// Only change code above this line
console.log(firstFive[i]);
}
}
countToFive();
```
# --solutions--
```js
function countToFive() {
let firstFive = "12345";
let len = firstFive.length;
// Only change code below this line
for (let i = 0; i < len; i++) {
// Only change code above this line
console.log(firstFive[i]);
}
}
countToFive();
```

View File

@ -3,6 +3,7 @@ id: 587d7b84367417b2b2512b36
title: 捕获未闭合的括号、方括号、大括号和引号
challengeType: 1
forumTopicId: 301190
dashedName: catch-unclosed-parentheses-brackets-braces-and-quotes
---
# --description--
@ -29,5 +30,20 @@ assert(code.match(/myArray\s*?=\s*?\[\s*?1\s*?,\s*?2\s*?,\s*?3\s*?\];/g));
assert(arraySum === 6);
```
# --seed--
## --seed-contents--
```js
let myArray = [1, 2, 3;
let arraySum = myArray.reduce((previous, current => previous + current);
console.log(`Sum of array values is: ${arraySum}`);
```
# --solutions--
```js
let myArray = [1, 2, 3];
let arraySum = myArray.reduce((previous, current) => previous + current);
console.log(`Sum of array values is: ${arraySum}`);
```

View File

@ -3,6 +3,7 @@ id: 587d7b85367417b2b2512b38
title: 捕获使用赋值运算符而不是相等运算符
challengeType: 1
forumTopicId: 301191
dashedName: catch-use-of-assignment-operator-instead-of-equality-operator
---
# --description--
@ -43,5 +44,36 @@ assert(result == 'Not equal!');
assert(code.match(/x\s*?===?\s*?y/g));
```
# --seed--
## --seed-contents--
```js
let x = 7;
let y = 9;
let result = "to come";
if(x = y) {
result = "Equal!";
} else {
result = "Not equal!";
}
console.log(result);
```
# --solutions--
```js
let x = 7;
let y = 9;
let result = "to come";
if(x === y) {
result = "Equal!";
} else {
result = "Not equal!";
}
console.log(result);
```

View File

@ -3,6 +3,7 @@ id: 587d7b86367417b2b2512b3d
title: 使用有效的终止条件防止无限循环
challengeType: 1
forumTopicId: 301192
dashedName: prevent-infinite-loops-with-a-valid-terminal-condition
---
# --description--
@ -39,5 +40,24 @@ assert(code.match(/i\s*?<=\s*?4;/g).length == 1);
assert(!code.match(/i\s*?!=\s*?4;/g));
```
# --seed--
## --seed-contents--
```js
function myFunc() {
for (let i = 1; i != 4; i += 2) {
console.log("Still going!");
}
}
```
# --solutions--
```js
function myFunc() {
for (let i = 1; i <= 4; i += 2) {
console.log("Still going!");
}
}
```

View File

@ -3,6 +3,7 @@ id: 587d7b83367417b2b2512b37
title: 了解 freeCodeCamp 和浏览器控制台之间的差异
challengeType: 1
forumTopicId: 301193
dashedName: understanding-the-differences-between-the-freecodecamp-and-browser-console
---
# --description--
@ -40,5 +41,30 @@ const noSpaces = code.replace(/\s/g, '');
assert(noSpaces.match(/console\.log\(output\)/));
```
# --seed--
## --seed-contents--
```js
// Open your browser console.
let output = "Get this to log once in the freeCodeCamp console and twice in the browser console";
// Use console.log() to print the output variable.
// Run the tests to see the difference between the two consoles.
// Now, add console.clear() before your console.log() to clear the browser console, and pass the tests.
```
# --solutions--
```js
// Open your browser console.
let output = "Get this to log once in the freeCodeCamp console and twice in the browser console";
// Use console.log() to print the output variable.
console.clear();
console.log(output);
// Run the tests to see the difference between the two consoles.
// Now, add console.clear() before your console.log() to clear the browser console, and pass the tests.
```

View File

@ -3,6 +3,7 @@ id: 587d7b86367417b2b2512b3c
title: 重新初始化循环中的变量时要小心
challengeType: 1
forumTopicId: 301194
dashedName: use-caution-when-reinitializing-variables-inside-a-loop
---
# --description--
@ -37,5 +38,52 @@ assert(
);
```
# --seed--
## --seed-contents--
```js
function zeroArray(m, n) {
// Creates a 2-D array with m rows and n columns of zeroes
let newArray = [];
let row = [];
for (let i = 0; i < m; i++) {
// Adds the m-th row into newArray
for (let j = 0; j < n; j++) {
// Pushes n zeroes into the current row to create the columns
row.push(0);
}
// Pushes the current row, which now has n zeroes in it, to the array
newArray.push(row);
}
return newArray;
}
let matrix = zeroArray(3, 2);
console.log(matrix);
```
# --solutions--
```js
function zeroArray(m, n) {
// Creates a 2-D array with m rows and n columns of zeroes
let newArray = [];
for (let i = 0; i < m; i++) {
let row = [];
// Adds the m-th row into newArray
for (let j = 0; j < n; j++) {
// Pushes n zeroes into the current row to create the columns
row.push(0);
}
// Pushes the current row, which now has n zeroes in it, to the array
newArray.push(row);
}
return newArray;
}
let matrix = zeroArray(3, 2);
console.log(matrix);
```

View File

@ -3,6 +3,7 @@ id: 587d7b83367417b2b2512b33
title: 使用控制台检查变量值
challengeType: 1
forumTopicId: 18372
dashedName: use-the-javascript-console-to-check-the-value-of-a-variable
---
# --description--
@ -29,5 +30,23 @@ Chrome 和 Firefox 都有出色的 JavaScript 控制台(也称为 DevTools
assert(code.match(/console\.log\(a\)/g));
```
# --seed--
## --seed-contents--
```js
let a = 5;
let b = 1;
a++;
// Only change code below this line
let sumAB = a + b;
console.log(sumAB);
```
# --solutions--
```js
var a = 5; console.log(a);
```

View File

@ -3,6 +3,7 @@ id: 587d7b84367417b2b2512b34
title: 使用 type of 检查变量的类型
challengeType: 1
forumTopicId: 18374
dashedName: use-typeof-to-check-the-type-of-a-variable
---
# --description--
@ -44,5 +45,20 @@ assert(code.match(/typeof[\( ]seven\)?/g));
assert(code.match(/typeof[\( ]three\)?/g));
```
# --seed--
## --seed-contents--
```js
let seven = 7;
let three = "3";
console.log(seven + three);
// Only change code below this line
```
# --solutions--
```js
let seven = 7;let three = "3";console.log(typeof seven);
console.log(typeof three);
```