diff --git a/curriculum/challenges/chinese/01-responsive-web-design/basic-html-and-html5/nest-an-anchor-element-within-a-paragraph.md b/curriculum/challenges/chinese/01-responsive-web-design/basic-html-and-html5/nest-an-anchor-element-within-a-paragraph.md
index 2f7c2ae759..448920a432 100644
--- a/curriculum/challenges/chinese/01-responsive-web-design/basic-html-and-html5/nest-an-anchor-element-within-a-paragraph.md
+++ b/curriculum/challenges/chinese/01-responsive-web-design/basic-html-and-html5/nest-an-anchor-element-within-a-paragraph.md
@@ -29,7 +29,7 @@ dashedName: nest-an-anchor-element-within-a-paragraph
` ... `
-`a` 元素内的内容文本 `link to freecodecamp.org` 叫作 `anchor text`(锚文本),会显示为一个可以点击的链接:
+`a` 元素内的文本 `link to freecodecamp.org` 叫作锚文本,会显示为一个可以点击的链接:
`link to freecodecamp.org`
@@ -43,15 +43,23 @@ dashedName: nest-an-anchor-element-within-a-paragraph
# --hints--
-应包含一个链接到 `https://freecatphotoapp.com` 的 `a` 元素。
+应该只有一个 `a` 元素。
```js
assert(
- $('a[href="https://freecatphotoapp.com"]').length > 0
+ $('a').length === 1
);
```
-`a` 元素的内容文本应为 `cat photos`。
+`a` 元素应该链接到 “`https://freecatphotoapp.com`”。
+
+```js
+assert(
+ $('a[href="https://freecatphotoapp.com"]').length === 1
+);
+```
+
+`a` 元素应该有锚文本 `cat photos`。
```js
assert(
@@ -61,13 +69,13 @@ assert(
);
```
-你应该在 `a` 标签的外部创建一个新的 `p` 标签。 页面中应至少包含 3 个 `p` 标签。
+应该创建一个新的 `p` 元素。 HTML 代码中应该总共有至少 3 个 `p` 标签。
```js
assert($('p') && $('p').length > 2);
```
-`a` 应嵌套在新创建的 `p` 元素内。
+`a` 元素应该被嵌套在新的 `p` 元素中。
```js
assert(
@@ -75,7 +83,7 @@ assert(
);
```
-`p` 元素应该包含文本 `View more`(请注意,more 之后有一个空格)。
+`p` 元素应该包含文本 `View more`(在它后面有一个空格)。
```js
assert(
@@ -86,7 +94,7 @@ assert(
);
```
-`a` 元素中 不 应包含文本 `View more`。
+`a` 元素不应该有文本 `View more`。
```js
assert(
@@ -96,7 +104,7 @@ assert(
);
```
-确保每个 `p` 元素有结束标签。
+每个 `p` 元素都应该有一个结束标签。
```js
assert(
@@ -106,7 +114,7 @@ assert(
);
```
-确保每个 `a` 元素有结束标签。
+每个 `a` 元素都应该有一个结束标签。
```js
assert(
diff --git a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-personal-portfolio-webpage.md b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-personal-portfolio-webpage.md
index 081b12cbe6..2b5444a94d 100644
--- a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-personal-portfolio-webpage.md
+++ b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-personal-portfolio-webpage.md
@@ -36,7 +36,7 @@ dashedName: build-a-personal-portfolio-webpage
**需求 11:** 导航栏应始终保持在视口顶部。
-你可以通过 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO) 来构建你的项目, 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
+你可以使用这个 CodePen 模版创建你自己的项目,点击 `Save` 即可创建你的新项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
完成项目并通过所有测试后,请输入你的项目在 CodePen 上的链接并提交。
diff --git a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-product-landing-page.md b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-product-landing-page.md
index 4a9e50a199..8da6213aa9 100644
--- a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-product-landing-page.md
+++ b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-product-landing-page.md
@@ -44,7 +44,7 @@ dashedName: build-a-product-landing-page
**需求 15:** 在此 app 中,应至少使用一次 CSS 的 flexbox 布局。
-你可以通过 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO) 来构建你的项目, 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
+你可以使用这个 CodePen 模版创建你自己的项目,点击 `Save` 即可创建你的新项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
完成项目并通过所有测试后,请输入你的项目在 CodePen 上的链接并提交。
diff --git a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md
index fba3d99267..544c2494fc 100644
--- a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md
+++ b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md
@@ -46,7 +46,7 @@ dashedName: build-a-survey-form
**需求 16:** 在表单元素内,应存在一个 `id="submit"` 的按钮,以便用户提交表单。
-你可以 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO)来创建你的项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
+你可以使用这个 CodePen 模版创建你自己的项目,点击 `Save` 即可创建你的新项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
完成项目并通过所有测试后,请输入你的项目在 CodePen 上的链接并提交。
diff --git a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-technical-documentation-page.md b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-technical-documentation-page.md
index 71c4636642..b16d78431d 100644
--- a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-technical-documentation-page.md
+++ b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-technical-documentation-page.md
@@ -44,7 +44,7 @@ dashedName: build-a-technical-documentation-page
**需求 15:** 在此 app 中,应至少使用一次媒体查询。
-你可以 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO) 来构建你的项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
+你可以使用这个 CodePen 模版创建你自己的项目,点击 `Save` 即可创建你的新项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
完成项目并通过所有测试后,请输入你的项目在 CodePen 上的链接并提交。
diff --git a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-tribute-page.md b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-tribute-page.md
index 683a16da15..7c57480657 100644
--- a/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-tribute-page.md
+++ b/curriculum/challenges/chinese/01-responsive-web-design/responsive-web-design-projects/build-a-tribute-page.md
@@ -32,7 +32,7 @@ dashedName: build-a-tribute-page
**需求 9:** `img` 应在其父元素内居中。
-你可以 fork [这个 CodePen 项目](https://codepen.io/freeCodeCamp/pen/MJjpwO) 来构建你的项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
+你可以使用这个 CodePen 模版创建你的新项目,点击 `Save` 即可创建你的新项目。 也可以使用此 CDN 链接在任何你喜欢的环境中运行测试:`https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js`。
完成项目并通过所有测试后,请输入你的项目在 CodePen 上的链接并提交。
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/add-items-using-splice.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/add-items-using-splice.md
index 04a8878555..e3ae163d15 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/add-items-using-splice.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/add-items-using-splice.md
@@ -1,6 +1,6 @@
---
id: 587d78b3367417b2b2512b11
-title: Add Items Using splice()
+title: 使用 splice() 添加元素
challengeType: 1
forumTopicId: 301152
dashedName: add-items-using-splice
@@ -8,7 +8,7 @@ dashedName: add-items-using-splice
# --description--
-Remember in the last challenge we mentioned that `splice()` can take up to three parameters? Well, you can use the third parameter, comprised of one or more element(s), to add to the array. This can be incredibly useful for quickly switching out an element, or a set of elements, for another.
+还记得在上个挑战中我们提到 `splice()` 方法最多可以接收 3 个参数吗? 第三个参数可以是一个或多个元素,这些元素会被添加到数组中。 这样,我们能够便捷地将数组中的一个或多个连续元素换成其他的元素。
```js
const numbers = [10, 11, 12, 12, 15];
@@ -16,20 +16,20 @@ const startIndex = 3;
const amountToDelete = 1;
numbers.splice(startIndex, amountToDelete, 13, 14);
-// the second entry of 12 is removed, and we add 13 and 14 at the same index
console.log(numbers);
-// returns [ 10, 11, 12, 13, 14, 15 ]
```
-Here, we begin with an array of numbers. Then, we pass the following to `splice()`: The index at which to begin deleting elements (3), the number of elements to be deleted (1), and the remaining arguments (13, 14) will be inserted starting at that same index. Note that there can be any number of elements (separated by commas) following `amountToDelete`, each of which gets inserted.
+`12` 的第二个条目已被删除,我们在同一索引处添加 `13` 和 `14`。 `numbers` 数组现在将会是 `[ 10, 11, 12, 13, 14, 15 ]`。
+
+在上面的代码中,数组一开始包含了若干数字。 接着,我们调用 `splice()` 方法,索引为 (3) 的地方开始删除元素,删除的元素数量是 (1)。然后,(13, 14) 是在删除位置插入的元素。 可以在 `amountToDelete` 后面传入任意数量的元素(以逗号分隔),每个都会被插入到数组中。
# --instructions--
-We have defined a function, `htmlColorNames`, which takes an array of HTML colors as an argument. Modify the function using `splice()` to remove the first two elements of the array and add `'DarkSalmon'` and `'BlanchedAlmond'` in their respective places.
+我们已经定义了一个 `htmlColorNames` 函数,它以一个 HTML 颜色的数组作为输入参数。 请修改这个函数,使用 `splice()` 来移除数组中的前两个元素,并在对应的位置上添加 `'DarkSalmon'` 和 `'BlanchedAlmond'`。
# --hints--
-`htmlColorNames` should return `["DarkSalmon", "BlanchedAlmond", "LavenderBlush", "PaleTurquoise", "FireBrick"]`
+`htmlColorNames` 应返回 `["DarkSalmon", "BlanchedAlmond", "LavenderBlush", "PaleTurquoise", "FireBrick"]`。
```js
assert.deepEqual(
@@ -50,19 +50,19 @@ assert.deepEqual(
);
```
-The `htmlColorNames` function should utilize the `splice()` method
+`htmlColorNames` 函数中应调用 `splice()` 方法。
```js
assert(/.splice/.test(code));
```
-You should not use `shift()` or `unshift()`.
+不应使用 `shift()` 或 `unshift()`。
```js
assert(!/shift|unshift/.test(code));
```
-You should not use array bracket notation.
+不应使用数组的方括号表示法。
```js
assert(!/\[\d\]\s*=/.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/add-key-value-pairs-to-javascript-objects.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/add-key-value-pairs-to-javascript-objects.md
index f5adc6e51b..ae4df94507 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/add-key-value-pairs-to-javascript-objects.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/add-key-value-pairs-to-javascript-objects.md
@@ -1,6 +1,6 @@
---
id: 587d7b7c367417b2b2512b18
-title: Add Key-Value Pairs to JavaScript Objects
+title: 将键值对添加到对象中
challengeType: 1
forumTopicId: 301153
dashedName: add-key-value-pairs-to-javascript-objects
@@ -8,7 +8,7 @@ dashedName: add-key-value-pairs-to-javascript-objects
# --description--
-At their most basic, objects are just collections of key-value pairs. In other words, they are pieces of data (values) mapped to unique identifiers called properties (keys). Take a look at an example:
+对象(object)本质上是键值对(key-value pair)的集合。 或者说,一系列被映射到唯一标识符的数据就是对象;习惯上,唯一标识符叫做属性(property)或者键(key);数据叫做值(value)。 让我们来看一个简单的例子:
```js
const tekkenCharacter = {
@@ -18,19 +18,19 @@ const tekkenCharacter = {
};
```
-The above code defines a Tekken video game character object called `tekkenCharacter`. It has three properties, each of which map to a specific value. If you want to add an additional property, such as "origin", it can be done by assigning `origin` to the object:
+上面的代码定义了一个叫做 `tekkenCharacter` 的“铁拳”游戏人物对象。 它有三个属性,每个属性都对应一个特定的值。 如果我们想为它再添加一个叫做 `origin` 的属性,可以这样写:
```js
tekkenCharacter.origin = 'South Korea';
```
-This uses dot notation. If you were to observe the `tekkenCharacter` object, it will now include the `origin` property. Hwoarang also had distinct orange hair. You can add this property with bracket notation by doing:
+上面的代码中,我们使用了点号表示法。 如果我们现在输出 `tekkenCharacter` 对象,便可以看到它具有 `origin` 属性。 接下来,因为这个人物在游戏中有着与众不同的橘色头发, 我们可以通过方括号表示法来为它添加这个属性,像这样:
```js
tekkenCharacter['hair color'] = 'dyed orange';
```
-Bracket notation is required if your property has a space in it or if you want to use a variable to name the property. In the above case, the property is enclosed in quotes to denote it as a string and will be added exactly as shown. Without quotes, it will be evaluated as a variable and the name of the property will be whatever value the variable is. Here's an example with a variable:
+如果要设置的属性中存在空格,或者要设置的属性是一个变量,那我们必须使用方括号表示法(bracket notation)来为对象添加属性。 在上面的代码中,我们把属性(hair color)放到引号里,以此来表示整个字符串都是需要设置的属性。 如果我们不加上引号,那么中括号里的内容会被当作一个变量来解析,这个变量对应的值就会作为要设置的属性, 请看这段代码:
```js
const eyes = 'eye color';
@@ -38,7 +38,7 @@ const eyes = 'eye color';
tekkenCharacter[eyes] = 'brown';
```
-After adding all the examples, the object will look like this:
+执行以上所有示例代码后,对象会变成这样:
```js
{
@@ -53,35 +53,35 @@ After adding all the examples, the object will look like this:
# --instructions--
-A `foods` object has been created with three entries. Using the syntax of your choice, add three more entries to it: `bananas` with a value of `13`, `grapes` with a value of `35`, and `strawberries` with a value of `27`.
+我们已经为你创建了包含三个项目的 `foods` 对象。 请使用上述任意语法,来为 foods 对象添加如下三个键值对:`bananas` 属性,值为 `13`;`grapes` 属性,值为 `35`;`strawberries` 属性,值为 `27`。
# --hints--
-`foods` should be an object.
+`foods` 应为一个对象。
```js
assert(typeof foods === 'object');
```
-The `foods` object should have a key `"bananas"` with a value of `13`.
+`foods` 应有一个值为 `13` 的 `bananas` 属性。
```js
assert(foods.bananas === 13);
```
-The `foods` object should have a key `"grapes"` with a value of `35`.
+`foods` 应有一个值为 `35` 的 `grapes` 属性。
```js
assert(foods.grapes === 35);
```
-The `foods` object should have a key `"strawberries"` with a value of `27`.
+`foods` 应有一个值为 `27` 的 `strawberries` 属性。
```js
assert(foods.strawberries === 27);
```
-The key-value pairs should be set using dot or bracket notation.
+应使用点号表示法或方括号表示法来设置对象的属性。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/check-for-the-presence-of-an-element-with-indexof.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/check-for-the-presence-of-an-element-with-indexof.md
index 4bc028927f..8dc1e7c888 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/check-for-the-presence-of-an-element-with-indexof.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/check-for-the-presence-of-an-element-with-indexof.md
@@ -1,6 +1,6 @@
---
id: 587d7b7b367417b2b2512b14
-title: Check For The Presence of an Element With indexOf()
+title: 使用 indexOf() 检查元素是否存在
challengeType: 1
forumTopicId: 301154
dashedName: check-for-the-presence-of-an-element-with-indexof
@@ -8,31 +8,33 @@ dashedName: check-for-the-presence-of-an-element-with-indexof
# --description--
-Since arrays can be changed, or *mutated*, at any time, there's no guarantee about where a particular piece of data will be on a given array, or if that element even still exists. Luckily, JavaScript provides us with another built-in method, `indexOf()`, that allows us to quickly and easily check for the presence of an element on an array. `indexOf()` takes an element as a parameter, and when called, it returns the position, or index, of that element, or `-1` if the element does not exist on the array.
+由于数组随时都可以修改或发生 *mutated*,我们很难保证某个数据始终处于数组中的特定位置,甚至不能保证该元素是否还存在于该数组中。 好消息是,JavaScript 为我们提供了内置方法 `indexOf()`。 这个方法让我们可以方便地检查某个元素是否存在于数组中。 `indexOf()` 方法接受一个元素作为输入参数,并返回该元素在数组中的位置(索引);若该元素不存在于数组中则返回 `-1`。
-For example:
+例如:
```js
let fruits = ['apples', 'pears', 'oranges', 'peaches', 'pears'];
-fruits.indexOf('dates'); // returns -1
-fruits.indexOf('oranges'); // returns 2
-fruits.indexOf('pears'); // returns 1, the first index at which the element exists
+fruits.indexOf('dates');
+fruits.indexOf('oranges');
+fruits.indexOf('pears');
```
+`indexOf('dates')` 返回 `-1`,`indexOf('oranges')` 返回 `2`,`indexOf('pears')` 返回 `1` (每个元素存在的第一个索引)。
+
# --instructions--
-`indexOf()` can be incredibly useful for quickly checking for the presence of an element on an array. We have defined a function, `quickCheck`, that takes an array and an element as arguments. Modify the function using `indexOf()` so that it returns `true` if the passed element exists on the array, and `false` if it does not.
+`indexOf()` 在快速检查一个数组中是否存在某个元素时非常有用。 我们已经定义了一个 `quickCheck` 函数,它接受一个数组和一个元素作为输入参数。 请通过 `indexOf()` 方法修改这个函数,使得当传入的参数在数组中存在时返回 `true`,否则返回 `false`。
# --hints--
-The `quickCheck` function should return a boolean (`true` or `false`), not a string (`"true"` or `"false"`)
+`quickCheck` 函数应返回一个布尔值(`true` 或 `false`),而不是一个字符串(`"true"` 或 `"false"`)。
```js
assert.isBoolean(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
```
-`quickCheck(["squash", "onions", "shallots"], "mushrooms")` should return `false`
+`quickCheck(["squash", "onions", "shallots"], "mushrooms")` 应返回 `false`。
```js
assert.strictEqual(
@@ -41,7 +43,7 @@ assert.strictEqual(
);
```
-`quickCheck(["onions", "squash", "shallots"], "onions")` should return `true`
+`quickCheck(["onions", "squash", "shallots"], "onions")` 应返回 `true`。
```js
assert.strictEqual(
@@ -50,19 +52,19 @@ assert.strictEqual(
);
```
-`quickCheck([3, 5, 9, 125, 45, 2], 125)` should return `true`
+`quickCheck([3, 5, 9, 125, 45, 2], 125)` 应返回 `true`。
```js
assert.strictEqual(quickCheck([3, 5, 9, 125, 45, 2], 125), true);
```
-`quickCheck([true, false, false], undefined)` should return `false`
+`quickCheck([true, false, false], undefined)` 应返回 `false`。
```js
assert.strictEqual(quickCheck([true, false, false], undefined), false);
```
-The `quickCheck` function should utilize the `indexOf()` method
+`quickCheck` 函数中应使用 `indexOf()` 方法。
```js
assert.notStrictEqual(quickCheck.toString().search(/\.indexOf\(/), -1);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property.md
index e2ac0392eb..31073bbc4e 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property.md
@@ -1,6 +1,6 @@
---
id: 587d7b7d367417b2b2512b1c
-title: Check if an Object has a Property
+title: 检查对象是否具有某个属性
challengeType: 1
forumTopicId: 301155
dashedName: check-if-an-object-has-a-property
@@ -8,21 +8,22 @@ dashedName: check-if-an-object-has-a-property
# --description--
-Now we can add, modify, and remove keys from objects. But what if we just wanted to know if an object has a specific property? JavaScript provides us with two different ways to do this. One uses the `hasOwnProperty()` method and the other uses the `in` keyword. If we have an object `users` with a property of `Alan`, we could check for its presence in either of the following ways:
+我们已经学习了如何添加、修改和移除对象中的属性。 但如果我们想知道一个对象中是否包含某个属性呢? JavaScript 为我们提供了两种不同的方式来实现这个功能: 一个是通过 `hasOwnProperty()` 方法,另一个是使用 `in` 关键字。 假如我们有一个 `users` 对象,为检查它是否含有 `Alan` 属性,可以这样写:
```js
users.hasOwnProperty('Alan');
'Alan' in users;
-// both return true
```
+这两者结果都应该为 `true`。
+
# --instructions--
-We've created an object, `users`, with some users in it and a function `isEveryoneHere`, which we pass the `users` object to as an argument. Finish writing this function so that it returns `true` only if the `users` object contains all four names, `Alan`, `Jeff`, `Sarah`, and `Ryan`, as keys, and `false` otherwise.
+我们已经定义了一个包含若干用户信息的 `users` 对象和一个 `isEveryoneHere` 函数,该函数接收 `users` 对象作为参数。 请完成该函数使其在 `users` 对象中同时包含 `Alan`、`Jeff`、`Sarah`、`Ryan` 四个属性时才返回 `true`,否则返回 `false`。
# --hints--
-The `users` object should only contain the keys `Alan`, `Jeff`, `Sarah`, and `Ryan`
+`users` 对象应该只包含 `Alan`、`Jeff`、`Sarah`、`Ryan` 4 个属性。
```js
assert(
@@ -34,13 +35,13 @@ assert(
);
```
-The function `isEveryoneHere` should return `true` if `Alan`, `Jeff`, `Sarah`, and `Ryan` are properties on the `users` object
+`isEveryoneHere` 函数在 `users` 对象包含 `Alan`、`Jeff`、`Sarah`、`Ryan` 4 个属性时应返回 `true`。
```js
assert(isEveryoneHere(users) === true);
```
-The function `isEveryoneHere` should return `false` if `Alan` is not a property on the `users` object
+`isEveryoneHere` 函数在 `users` 对象不包含 `Alan` 时应返回 `false`。
```js
assert(
@@ -51,7 +52,7 @@ assert(
);
```
-The function `isEveryoneHere` should return `false` if `Jeff` is not a property on the `users` object
+`isEveryoneHere` 函数在 `users` 对象不包含 `Jeff` 时应返回 `false`。
```js
assert(
@@ -62,7 +63,7 @@ assert(
);
```
-The function `isEveryoneHere` should return `false` if `Sarah` is not a property on the `users` object
+`isEveryoneHere` 函数在 `users` 对象不包含 `Sarah` 时应返回 `false`。
```js
assert(
@@ -73,7 +74,7 @@ assert(
);
```
-The function `isEveryoneHere` should return `false` if `Ryan` is not a property on the `users` object
+`isEveryoneHere` 函数在 `users` 对象不包含 `Ryan` 时应返回 `false`。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/combine-arrays-with-the-spread-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/combine-arrays-with-the-spread-operator.md
index 0a27f7bb09..a52ac332b2 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/combine-arrays-with-the-spread-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/combine-arrays-with-the-spread-operator.md
@@ -1,6 +1,6 @@
---
id: 587d7b7b367417b2b2512b17
-title: Combine Arrays with the Spread Operator
+title: 使用展开运算符合并数组
challengeType: 1
forumTopicId: 301156
dashedName: combine-arrays-with-the-spread-operator
@@ -8,30 +8,31 @@ dashedName: combine-arrays-with-the-spread-operator
# --description--
-Another huge advantage of the spread operator, is the ability to combine arrays, or to insert all the elements of one array into another, at any index. With more traditional syntaxes, we can concatenate arrays, but this only allows us to combine arrays at the end of one, and at the start of another. Spread syntax makes the following operation extremely simple:
+展开语法(spread)的另一个重要用途是合并数组,或者将某个数组的所有元素插入到另一个数组的任意位置。 我们也可以使用 ES5 的语法连接两个数组,但只能让它们首尾相接。 而展开语法可以让这样的操作变得极其简单:
```js
let thisArray = ['sage', 'rosemary', 'parsley', 'thyme'];
let thatArray = ['basil', 'cilantro', ...thisArray, 'coriander'];
-// thatArray now equals ['basil', 'cilantro', 'sage', 'rosemary', 'parsley', 'thyme', 'coriander']
```
-Using spread syntax, we have just achieved an operation that would have been more complex and more verbose had we used traditional methods.
+`thatArray` 会有值 `['basil', 'cilantro', 'sage', 'rosemary', 'parsley', 'thyme', 'coriander']`
+
+使用展开语法,我们就可以很方便的实现一个用传统方法会写得很复杂且冗长的操作。
# --instructions--
-We have defined a function `spreadOut` that returns the variable `sentence`. Modify the function using the spread operator so that it returns the array `['learning', 'to', 'code', 'is', 'fun']`.
+我们已经定义了一个返回 `sentence` 变量的 `spreadOut` 函数。 请修改这个函数,利用 spread 使该函数返回数组 `['learning', 'to', 'code', 'is', 'fun']`。
# --hints--
-`spreadOut` should return `["learning", "to", "code", "is", "fun"]`
+`spreadOut` 应返回 `["learning", "to", "code", "is", "fun"]`。
```js
assert.deepEqual(spreadOut(), ['learning', 'to', 'code', 'is', 'fun']);
```
-The `spreadOut` function should utilize spread syntax
+`spreadOut` 函数里应用到展开语法。
```js
assert.notStrictEqual(spreadOut.toString().search(/[...]/), -1);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.md
index ca3aa490b5..e8f601ffc3 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-an-array-with-the-spread-operator.md
@@ -1,6 +1,6 @@
---
id: 587d7b7b367417b2b2512b13
-title: Copy an Array with the Spread Operator
+title: 使用展开运算符复制数组
challengeType: 1
forumTopicId: 301157
dashedName: copy-an-array-with-the-spread-operator
@@ -8,24 +8,24 @@ dashedName: copy-an-array-with-the-spread-operator
# --description--
-While `slice()` allows us to be selective about what elements of an array to copy, among several other useful tasks, ES6's new spread operator allows us to easily copy *all* of an array's elements, in order, with a simple and highly readable syntax. The spread syntax simply looks like this: `...`
+`slice()` 可以让我们从一个数组中选择一些元素来复制到新数组中,而 ES6 中又引入了一个简洁且可读性强的语法:展开运算符(spread operator),它能让我们方便地复制数组中的*所有*元素。 展开语法写出来是这样:`...`
-In practice, we can use the spread operator to copy an array like so:
+我们可以用展开运算符来复制数组:
```js
let thisArray = [true, true, undefined, false, null];
let thatArray = [...thisArray];
-// thatArray equals [true, true, undefined, false, null]
-// thisArray remains unchanged and thatArray contains the same elements as thisArray
```
+`thatArray` 等于 `[true, true, undefined, false, null]`。 `thisArray` 保持不变, `thatArray` 包含与 `thisArray` 相同的元素。
+
# --instructions--
-We have defined a function, `copyMachine` which takes `arr` (an array) and `num` (a number) as arguments. The function is supposed to return a new array made up of `num` copies of `arr`. We have done most of the work for you, but it doesn't work quite right yet. Modify the function using spread syntax so that it works correctly (hint: another method we have already covered might come in handy here!).
+我们已经定义了一个 `copyMachine` 函数,它接受 `arr`(一个数组)和 `num`(一个数字)作为输入参数。 该函数需要返回一个由 `num` 个 `arr` 组成的新的二维数组。 同时,我们写好了大致的流程,只是细节实现还没有写完。 请修改这个函数,使用展开语法,使该函数能正常工作(提示:我们已经学到过的一个方法很适合用在这里)!
# --hints--
-`copyMachine([true, false, true], 2)` should return `[[true, false, true], [true, false, true]]`
+`copyMachine([true, false, true], 2)` 应返回 `[[true, false, true], [true, false, true]]`。
```js
assert.deepEqual(copyMachine([true, false, true], 2), [
@@ -34,7 +34,7 @@ assert.deepEqual(copyMachine([true, false, true], 2), [
]);
```
-`copyMachine([1, 2, 3], 5)` should return `[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]`
+`copyMachine([1, 2, 3], 5)` 应返回 `[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]`。
```js
assert.deepEqual(copyMachine([1, 2, 3], 5), [
@@ -46,13 +46,13 @@ assert.deepEqual(copyMachine([1, 2, 3], 5), [
]);
```
-`copyMachine([true, true, null], 1)` should return `[[true, true, null]]`
+`copyMachine([true, true, null], 1)` 应返回 `[[true, true, null]]`。
```js
assert.deepEqual(copyMachine([true, true, null], 1), [[true, true, null]]);
```
-`copyMachine(["it works"], 3)` should return `[["it works"], ["it works"], ["it works"]]`
+`copyMachine(["it works"], 3)` 应返回 `[["it works"], ["it works"], ["it works"]]`。
```js
assert.deepEqual(copyMachine(['it works'], 3), [
@@ -62,7 +62,7 @@ assert.deepEqual(copyMachine(['it works'], 3), [
]);
```
-The `copyMachine` function should utilize the `spread operator` with array `arr`
+`copyMachine` 函数中应对 `arr` 使用展开运算符(`spread operator`)。
```js
assert(__helpers.removeJSComments(code).match(/\.\.\.arr/));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-array-items-using-slice.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-array-items-using-slice.md
index 54ba5bade9..8b90badcd0 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-array-items-using-slice.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/copy-array-items-using-slice.md
@@ -1,6 +1,6 @@
---
id: 587d7b7a367417b2b2512b12
-title: Copy Array Items Using slice()
+title: 使用 slice() 复制数组元素
challengeType: 1
forumTopicId: 301158
dashedName: copy-array-items-using-slice
@@ -8,25 +8,25 @@ dashedName: copy-array-items-using-slice
# --description--
-The next method we will cover is `slice()`. Rather than modifying an array, `slice()` copies or *extracts* a given number of elements to a new array, leaving the array it is called upon untouched. `slice()` takes only 2 parameters — the first is the index at which to begin extraction, and the second is the index at which to stop extraction (extraction will occur up to, but not including the element at this index). Consider this:
+接下来我们要介绍 `slice()` 方法。 `slice()` 不会修改数组,而是会复制,或者说*提取(extract)*给定数量的元素到一个新数组。 `slice()` 只接收 2 个输入参数:第一个是开始提取元素的位置(索引),第二个是提取元素的结束位置(索引)。 提取的元素中不包括第二个参数所对应的元素。 如下示例:
```js
let weatherConditions = ['rain', 'snow', 'sleet', 'hail', 'clear'];
let todaysWeather = weatherConditions.slice(1, 3);
-// todaysWeather equals ['snow', 'sleet'];
-// weatherConditions still equals ['rain', 'snow', 'sleet', 'hail', 'clear']
```
-In effect, we have created a new array by extracting elements from an existing array.
+`todaysWeather` 值为 `['snow', 'sleet']`,`weatherConditions` 值仍然为 `['rain', 'snow', 'sleet', 'hail', 'clear']`。
+
+在上面的代码中,我们从一个数组中提取了一些元素,并用这些元素创建了一个新数组。
# --instructions--
-We have defined a function, `forecast`, that takes an array as an argument. Modify the function using `slice()` to extract information from the argument array and return a new array that contains the elements `'warm'` and `'sunny'`.
+我们已经定义了一个 `forecast` 函数,它接受一个数组作为参数。 请修改这个函数,利用 `slice()` 从输入的数组中提取信息,最终返回一个包含元素 `warm` 和 `sunny` 的新数组。
# --hints--
-`forecast` should return `["warm", "sunny"]`
+`forecast` 应返回 `["warm", "sunny"]`。
```js
assert.deepEqual(
@@ -35,7 +35,7 @@ assert.deepEqual(
);
```
-The `forecast` function should utilize the `slice()` method
+`forecast` 函数中应使用 `slice()` 方法。
```js
assert(/\.slice\(/.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/create-complex-multi-dimensional-arrays.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/create-complex-multi-dimensional-arrays.md
index d15e24bcd4..fdf3161b6f 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/create-complex-multi-dimensional-arrays.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/create-complex-multi-dimensional-arrays.md
@@ -1,6 +1,6 @@
---
id: 587d7b7b367417b2b2512b16
-title: Create complex multi-dimensional arrays
+title: 创建复杂的多维数组
challengeType: 1
forumTopicId: 301159
dashedName: create-complex-multi-dimensional-arrays
@@ -8,52 +8,54 @@ dashedName: create-complex-multi-dimensional-arrays
# --description--
-Awesome! You have just learned a ton about arrays! This has been a fairly high level overview, and there is plenty more to learn about working with arrays, much of which you will see in later sections. But before moving on to looking at Objects, lets take one more look, and see how arrays can become a bit more complex than what we have seen in previous challenges.
+很好! 你现在已经学到很多关于数组的知识了, 但这些只是个开始。我们将在接下来的中挑战中学到更多与数组相关的知识。 在继续学习对象(Objects)之前,让我们再花一点时间了解下更复杂的数组嵌套。
-One of the most powerful features when thinking of arrays as data structures, is that arrays can contain, or even be completely made up of other arrays. We have seen arrays that contain arrays in previous challenges, but fairly simple ones. However, arrays can contain an infinite depth of arrays that can contain other arrays, each with their own arbitrary levels of depth, and so on. In this way, an array can very quickly become very complex data structure, known as a multi-dimensional, or nested array. Consider the following example:
+数组的一个强大的特性是,它可以包含其他数组,甚至完全由其他数组组成。 在上一个挑战中,我们已经接触到了包含数组的数组,但它还算是比较简单的。 数组中的数组还可以再包含其他数组,即可以嵌套任意多层数组。 习惯上,我们称这种数据结构为多维(multi-dimensional)数组或嵌套(nested)数组。 请看如下的示例:
```js
-let nestedArray = [ // top, or first level - the outer most array
- ['deep'], // an array within an array, 2 levels of depth
+let nestedArray = [
+ ['deep'],
[
- ['deeper'], ['deeper'] // 2 arrays nested 3 levels deep
+ ['deeper'], ['deeper']
],
[
[
- ['deepest'], ['deepest'] // 2 arrays nested 4 levels deep
+ ['deepest'], ['deepest']
],
[
[
- ['deepest-est?'] // an array nested 5 levels deep
+ ['deepest-est?']
]
]
]
];
```
-While this example may seem convoluted, this level of complexity is not unheard of, or even unusual, when dealing with large amounts of data. However, we can still very easily access the deepest levels of an array this complex with bracket notation:
+`deep` 数组已嵌套 2 层。 `deeper` 数组嵌套了 3 层。 `deepest` 数组嵌套了 3 层, `deepest-est?` 嵌套了 5 层。
+
+虽然这个例子看起来错综复杂,不过,尤其是在处理大量数据的时候,这种数据结构还是会用到的。 尽管结构复杂,不过我们仍可以通过方括号表示法来访问嵌套得最深的数组:
```js
console.log(nestedArray[2][1][0][0][0]);
-// logs: deepest-est?
```
-And now that we know where that piece of data is, we can reset it if we need to:
+控制台打印的是字符串 `deepest-est?`。 既然我们知道数据的位置,当然,我们也可以修改它:
```js
nestedArray[2][1][0][0][0] = 'deeper still';
console.log(nestedArray[2][1][0][0][0]);
-// now logs: deeper still
```
+现在控制台打印的是 `deeper still`。
+
# --instructions--
-We have defined a variable, `myNestedArray`, set equal to an array. Modify `myNestedArray`, using any combination of strings, numbers, and booleans for data elements, so that it has exactly five levels of depth (remember, the outer-most array is level 1). Somewhere on the third level, include the string `'deep'`, on the fourth level, include the string `'deeper'`, and on the fifth level, include the string `'deepest'`.
+我们已经定义了一个叫做 `myNestedArray` 的数组变量。 请修改 `myNestedArray`,使用字符串(string)、数字(number)或布尔值(boolean)的任意组合作为数组的元素,并让 myNestedArray 刚好有 5 层(注意,最外层的数组是第 1 层)。 同时,请在第 3 层的数组中包含字符串 `deep`;在第 4 层的数组中包含字符串 `deeper`,在第 5 层的数组中包含字符串 `deepest`。
# --hints--
-`myNestedArray` should contain only numbers, booleans, and strings as data elements
+`myNestedArray` 中的数据元素应只包含字符串、数字或者布尔值。
```js
assert.strictEqual(
@@ -77,7 +79,7 @@ assert.strictEqual(
);
```
-`myNestedArray` should have exactly 5 levels of depth
+`myNestedArray` 应刚好包含 5 层嵌套数组。
```js
assert.strictEqual(
@@ -100,7 +102,7 @@ assert.strictEqual(
);
```
-`myNestedArray` should contain exactly one occurrence of the string `"deep"` on an array nested 3 levels deep
+`myNestedArray` 中应只有一个字符串 `deep`,并且应出现在第 3 层数组中。
```js
assert(
@@ -129,7 +131,7 @@ assert(
);
```
-`myNestedArray` should contain exactly one occurrence of the string `"deeper"` on an array nested 4 levels deep
+`myNestedArray` 中应只有一个字符串 `deeper`,并且应出现在第 4 层数组中。
```js
assert(
@@ -158,7 +160,7 @@ assert(
);
```
-`myNestedArray` should contain exactly one occurrence of the string `"deepest"` on an array nested 5 levels deep
+`myNestedArray` 中应只有一个字符串 `deepest`,并且应出现在第 5 层数组中。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-all-an-arrays-items-using-for-loops.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-all-an-arrays-items-using-for-loops.md
index 6674711f21..7e6d865dfb 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-all-an-arrays-items-using-for-loops.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-all-an-arrays-items-using-for-loops.md
@@ -1,6 +1,6 @@
---
id: 587d7b7b367417b2b2512b15
-title: Iterate Through All an Array's Items Using For Loops
+title: 使用 for 循环遍历数组中的全部元素
challengeType: 1
forumTopicId: 301161
dashedName: iterate-through-all-an-arrays-items-using-for-loops
@@ -8,9 +8,9 @@ dashedName: iterate-through-all-an-arrays-items-using-for-loops
# --description--
-Sometimes when working with arrays, it is very handy to be able to iterate through each item to find one or more elements that we might need, or to manipulate an array based on which data items meet a certain set of criteria. JavaScript offers several built in methods that each iterate over arrays in slightly different ways to achieve different results (such as `every()`, `forEach()`, `map()`, etc.), however the technique which is most flexible and offers us the greatest amount of control is a simple `for` loop.
+使用数组时,我们经常需要遍历数组的所有元素来找出我们需要的一个或多个元素,抑或是对数组执行一些特定的操作。 JavaScript 为我们提供了几个内置的方法,它们以不同的方式遍历数组,以便我们可以用于不同的场景(如 `every()`、`forEach()`、`map()` 等等)。 然而,最简单的 `for` 循环不仅能实现上述这些方法的功能,而且相比之下也会更加灵活。
-Consider the following:
+请看以下的例子:
```js
function greaterThanTen(arr) {
@@ -24,18 +24,17 @@ function greaterThanTen(arr) {
}
greaterThanTen([2, 12, 8, 14, 80, 0, 1]);
-// returns [12, 14, 80]
```
-Using a `for` loop, this function iterates through and accesses each element of the array, and subjects it to a simple test that we have created. In this way, we have easily and programmatically determined which data items are greater than `10`, and returned a new array containing those items.
+在这个函数中,我们用一个 `for` 循环来遍历数组,逐一对其中的元素进行判断。 通过上面的代码,我们可以找出数组中大于 `10` 的所有元素,并返回一个包含这些元素的新数组 `[12, 14, 80]`。
# --instructions--
-We have defined a function, `filteredArray`, which takes `arr`, a nested array, and `elem` as arguments, and returns a new array. `elem` represents an element that may or may not be present on one or more of the arrays nested within `arr`. Modify the function, using a `for` loop, to return a filtered version of the passed array such that any array nested within `arr` containing `elem` has been removed.
+我们已经定义了 `filteredArray` 函数,它接受一个嵌套的数组 `arr` 和一个 `elem` 作为参数,并要返回一个新数组。 `arr` 数组中嵌套的数组里可能包含 `elem` 元素,也可能不包含。 请修改该函数,用一个 `for` 循环来做筛选,使函数返回一个由 `arr` 中不包含 `elem` 的数组所组成的新数组。
# --hints--
-`filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18)` should return `[ [10, 8, 3], [14, 6, 23] ]`
+`filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18)` 应返回 `[[10, 8, 3], [14, 6, 23]]`。
```js
assert.deepEqual(
@@ -54,7 +53,7 @@ assert.deepEqual(
);
```
-`filteredArray([ ["trumpets", 2], ["flutes", 4], ["saxophones", 2] ], 2)` should return `[ ["flutes", 4] ]`
+`filteredArray([["trumpets", 2], ["flutes", 4], ["saxophones", 2]], 2)` 应返回 `[["flutes", 4]]`。
```js
assert.deepEqual(
@@ -70,7 +69,7 @@ assert.deepEqual(
);
```
-`filteredArray([ ["amy", "beth", "sam"], ["dave", "sean", "peter"] ], "peter")` should return `[ ["amy", "beth", "sam"] ]`
+`filteredArray([["amy", "beth", "sam"], ["dave", "sean", "peter"]], "peter")` 应返回 `[["amy", "beth", "sam"]]`。
```js
assert.deepEqual(
@@ -85,7 +84,7 @@ assert.deepEqual(
);
```
-`filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3)` should return `[ ]`
+`filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3)` 应返回 `[]`。
```js
assert.deepEqual(
@@ -102,7 +101,7 @@ assert.deepEqual(
);
```
-The `filteredArray` function should utilize a `for` loop
+`filteredArray` 函数中应使用 `for` 循环。
```js
assert.notStrictEqual(filteredArray.toString().search(/for/), -1);
diff --git a/curriculum/challenges/chinese/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/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for...in-statement.md
index 390132b504..f59f9f6fac 100644
--- a/curriculum/challenges/chinese/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/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for...in-statement.md
@@ -1,6 +1,6 @@
---
id: 587d7b7d367417b2b2512b1d
-title: Iterate Through the Keys of an Object with a for...in Statement
+title: 使用 for...in 语句遍历对象
challengeType: 1
forumTopicId: 301162
dashedName: iterate-through-the-keys-of-an-object-with-a-for---in-statement
@@ -8,25 +8,23 @@ dashedName: iterate-through-the-keys-of-an-object-with-a-for---in-statement
# --description--
-Sometimes you may need to iterate through all the keys within an object. This requires a specific syntax in JavaScript called a for...in statement. For our `users` object, this could look like:
+如果我们想要遍历对象中的所有属性, 只需要使用 JavaScript 中的 for...in 语句即可。 以遍历 `users` 对象的属性为例:
```js
for (let user in users) {
console.log(user);
}
-
-// logs:
-Alan
-Jeff
-Sarah
-Ryan
```
-In this statement, we defined a variable `user`, and as you can see, this variable was reset during each iteration to each of the object's keys as the statement looped through the object, resulting in each user's name being printed to the console. **NOTE:** Objects do not maintain an ordering to stored keys like arrays do; thus a key's position on an object, or the relative order in which it appears, is irrelevant when referencing or accessing that key.
+这将在控制台打印 `Alan`、`Jeff`、`Sarah` 和 `Ryan` - 每个值占一行。
+
+在上面的代码中,我们定义了一个 `user` 变量。 可以观察到,这个变量在遍历对象的语句执行过程中会一直被重置并赋予新值,结果就是不同的用户名打印到了 console 中。
+
+**注意:**对象中的键是无序的,这与数组不同。 因此,一个对象中某个属性的位置,或者说它出现的相对顺序,在引用或访问该属性时是不确定的。
# --instructions--
-We've defined a function `countOnline` which accepts one argument (a users object). Use a for...in statement within this function to loop through the users object passed into the function and return the number of users whose `online` property is set to `true`. An example of a users object which could be passed to `countOnline` is shown below. Each user will have an `online` property with either a `true` or `false` value.
+我们已经定义了一个 `countOnline` 函数,它接收一个 users 对象参数。 请在其中使用 for...in 语句来遍历传入函数的 users 对象中的用户,并返回 `online` 属性为 `true` 的用户数量。 以下是一个传入 `countOnline` 函数的对象示例, 注意每个用户都有 `online` 属性,其属性值为 `true` 或 `false`:
```js
{
@@ -44,7 +42,7 @@ We've defined a function `countOnline` which accepts one argument (a users objec
# --hints--
-The function `countOnline` should use a `for in` statement to iterate through the object keys of the object passed to it.
+函数 `countOnline` 中应使用 `for in` 语句遍历传入的对象的对象键。
```js
assert(
@@ -54,19 +52,19 @@ assert(
);
```
-The function `countOnline` should return `1` when the object `{ Alan: { online: false }, Jeff: { online: true }, Sarah: { online: false } }` is passed to it
+当传入 `{ Alan: { online: false }, Jeff: { online: true }, Sarah: { online: false } }` 时,函数 `countOnline` 应该返回 `1`。
```js
assert(countOnline(usersObj1) === 1);
```
-The function `countOnline` should return `2` when the object `{ Alan: { online: true }, Jeff: { online: false }, Sarah: { online: true } }` is passed to it
+当传入 `{ Alan: { online: true }, Jeff: { online: false }, Sarah: { online: true } }` 时,函数 `countOnline` 应该返回 `2`。
```js
assert(countOnline(usersObj2) === 2);
```
-The function `countOnline` should return `0` when the object `{ Alan: { online: false }, Jeff: { online: false }, Sarah: { online: false } }` is passed to it
+当传入 `{ Alan: { online: false }, Jeff: { online: false }, Sarah: { online: false } }` 时,函数 `countOnline` 应该返回 `0`。
```js
assert(countOnline(usersObj3) === 0);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-from-an-array-with-pop-and-shift.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-from-an-array-with-pop-and-shift.md
index 9cb6b79038..4d7402fb85 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-from-an-array-with-pop-and-shift.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-from-an-array-with-pop-and-shift.md
@@ -1,6 +1,6 @@
---
id: 587d78b2367417b2b2512b0f
-title: Remove Items from an Array with pop() and shift()
+title: 使用 pop() 和 shift() 从数组中删除元素
challengeType: 1
forumTopicId: 301165
dashedName: remove-items-from-an-array-with-pop-and-shift
@@ -8,35 +8,39 @@ dashedName: remove-items-from-an-array-with-pop-and-shift
# --description--
-Both `push()` and `unshift()` have corresponding methods that are nearly functional opposites: `pop()` and `shift()`. As you may have guessed by now, instead of adding, `pop()` *removes* an element from the end of an array, while `shift()` removes an element from the beginning. The key difference between `pop()` and `shift()` and their cousins `push()` and `unshift()`, is that neither method takes parameters, and each only allows an array to be modified by a single element at a time.
+`push()` 和 `unshift()` 都有一个与它们作用相反的函数:`pop()` 和 `shift()`。 与插入元素相反,`pop()` 会从数组的末尾*移除*一个元素,而 `shift()` 会从数组的开头移除一个元素。 `pop()` 和 `shift()` 与 `push()` 和 `unshift()` 的关键区别在于,用于删除元素的方法不接收参数,而且每次只能删除数组中的一个元素。
-Let's take a look:
+让我们来看以下的例子:
```js
let greetings = ['whats up?', 'hello', 'see ya!'];
greetings.pop();
-// now equals ['whats up?', 'hello']
-
-greetings.shift();
-// now equals ['hello']
```
-We can also return the value of the removed element with either method like this:
+`greetings` 值为 `['whats up?', 'hello']`。
+
+```js
+greetings.shift();
+```
+
+`greetings` 值为 `['hello']`。
+
+这些用于删除数组元素的方法会返回被删除的元素:
```js
let popped = greetings.pop();
-// returns 'hello'
-// greetings now equals []
```
+`greetings` 值为 `[]`,`popped` 值为 `hello`。
+
# --instructions--
-We have defined a function, `popShift`, which takes an array as an argument and returns a new array. Modify the function, using `pop()` and `shift()`, to remove the first and last elements of the argument array, and assign the removed elements to their corresponding variables, so that the returned array contains their values.
+我们已经定义了一个 `popShift` 函数,它接收一个数组作为输入参数并返回一个新的数组。 请修改这个函数,使用 `pop()` 和 `shift()` 来移除输入的数组中的第一个元素和最后一个元素,并将这两个被移除的元素分别赋值给对应的变量,使得最终返回的数组里包含这两个值。
# --hints--
-`popShift(["challenge", "is", "not", "complete"])` should return `["challenge", "complete"]`
+`popShift(["challenge", "is", "not", "complete"])` 应返回 `["challenge", "complete"]`。
```js
assert.deepEqual(popShift(['challenge', 'is', 'not', 'complete']), [
@@ -45,13 +49,13 @@ assert.deepEqual(popShift(['challenge', 'is', 'not', 'complete']), [
]);
```
-The `popShift` function should utilize the `pop()` method
+`popShift` 函数中应使用 `pop()` 方法。
```js
assert.notStrictEqual(popShift.toString().search(/\.pop\(/), -1);
```
-The `popShift` function should utilize the `shift()` method
+`popShift` 函数中应使用 `shift()` 方法。
```js
assert.notStrictEqual(popShift.toString().search(/\.shift\(/), -1);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-using-splice.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-using-splice.md
index ce579da8e7..f09cad0542 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-using-splice.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/remove-items-using-splice.md
@@ -1,6 +1,6 @@
---
id: 587d78b2367417b2b2512b10
-title: Remove Items Using splice()
+title: 使用 splice() 删除元素
challengeType: 1
forumTopicId: 301166
dashedName: remove-items-using-splice
@@ -8,34 +8,35 @@ dashedName: remove-items-using-splice
# --description--
-Ok, so we've learned how to remove elements from the beginning and end of arrays using `shift()` and `pop()`, but what if we want to remove an element from somewhere in the middle? Or remove more than one element at once? Well, that's where `splice()` comes in. `splice()` allows us to do just that: **remove any number of consecutive elements** from anywhere in an array.
+在之前的挑战中,我们已经学习了如何用 `shift()` 和 `pop()` 从数组的开头或末尾移除元素。 但如果我们想删除数组中间的一个元素, 或者想一次删除多个元素,该如何操作呢? 这时候我们就需要使用 `splice()` 方法了, `splice()` 可以让我们从数组中的任意位置**连续删除任意数量的元素**。
-`splice()` can take up to 3 parameters, but for now, we'll focus on just the first 2. The first two parameters of `splice()` are integers which represent indexes, or positions, of the array that `splice()` is being called upon. And remember, arrays are *zero-indexed*, so to indicate the first element of an array, we would use `0`. `splice()`'s first parameter represents the index on the array from which to begin removing elements, while the second parameter indicates the number of elements to delete. For example:
+`splice()` 最多可以接受 3 个参数,但现在我们先关注前两个。 `splice()` 接收的前两个参数是整数,表示正在调用 的`splice()` 数组中的元素的索引或位置。 别忘了,数组的索引是*从 0 开始的*,所以我们要用 `0` 来表示数组中的第一个元素。 `splice()` 的第一个参数代表从数组中的哪个索引开始移除元素,而第二个参数表示要从数组中的这个位置开始删除多少个元素。 例如:
```js
let array = ['today', 'was', 'not', 'so', 'great'];
array.splice(2, 2);
-// remove 2 elements beginning with the 3rd element
-// array now equals ['today', 'was', 'great']
```
-`splice()` not only modifies the array it's being called on, but it also returns a new array containing the value of the removed elements:
+这里我们移除 2 个元素,首先是第三个元素(索引为 2)。 `array` 会有值 `['today', 'was', 'great']`。
+
+`splice()` 不仅会修改调用该方法的数组,还会返回一个包含被移除元素的数组:
```js
let array = ['I', 'am', 'feeling', 'really', 'happy'];
let newArray = array.splice(3, 2);
-// newArray equals ['really', 'happy']
```
+`newArray` 值为 `['really', 'happy']`。
+
# --instructions--
-We've initialized an array `arr`. Use `splice()` to remove elements from `arr`, so that it only contains elements that sum to the value of `10`.
+我们已经定义了数组 `arr`。 请使用 `splice()` 从 `arr` 里移除元素,使剩余的元素之和为 `10`。
# --hints--
-You should not change the original line of `const arr = [2, 4, 5, 1, 7, 5, 2, 1];`.
+不应修改这一行 `const arr = [2, 4, 5, 1, 7, 5, 2, 1];`。
```js
assert(
@@ -43,7 +44,7 @@ assert(
);
```
-`arr` should only contain elements that sum to `10`.
+`arr` 的剩余元素之和应为 `10`。
```js
assert.strictEqual(
@@ -52,13 +53,13 @@ assert.strictEqual(
);
```
-Your code should utilize the `splice()` method on `arr`.
+应对 `arr` 调用 `splice()` 方法。
```js
assert(__helpers.removeWhiteSpace(code).match(/arr\.splice\(/));
```
-The splice should only remove elements from `arr` and not add any additional elements to `arr`.
+splice 应只删除 `arr` 里面的元素,不能给 `arr` 添加元素。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/use-an-array-to-store-a-collection-of-data.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/use-an-array-to-store-a-collection-of-data.md
index 61f8b4f1c3..3ff59662eb 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/use-an-array-to-store-a-collection-of-data.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-data-structures/use-an-array-to-store-a-collection-of-data.md
@@ -1,6 +1,6 @@
---
id: 587d7b7e367417b2b2512b20
-title: Use an Array to Store a Collection of Data
+title: 使用数组存储不同类型的数据
challengeType: 1
forumTopicId: 301167
dashedName: use-an-array-to-store-a-collection-of-data
@@ -8,15 +8,16 @@ dashedName: use-an-array-to-store-a-collection-of-data
# --description--
-The below is an example of the simplest implementation of an array data structure. This is known as a one-dimensional array, meaning it only has one level, or that it does not have any other arrays nested within it. Notice it contains booleans, strings, and numbers, among other valid JavaScript data types:
+以下是最简单的数组(Array)示例: 这是一个一维数组(one-dimensional array),它只有一层,或者说它里面没有包含其它数组。 可以观察到,这个数组中只包含了布尔值(booleans)、字符串(strings)、数字(numbers)以及 JavaScript 中的其他数据类型:
```js
let simpleArray = ['one', 2, 'three', true, false, undefined, null];
console.log(simpleArray.length);
-// logs 7
```
-All arrays have a length property, which as shown above, can be very easily accessed with the syntax `Array.length`. A more complex implementation of an array can be seen below. This is known as a multi-dimensional array, or an array that contains other arrays. Notice that this array also contains JavaScript objects, which we will examine very closely in our next section, but for now, all you need to know is that arrays are also capable of storing complex objects.
+调用 `console.log` 显示 `7`。
+
+所有数组都有一个表示长度的属性,我们可以通过 `Array.length` 来访问它。 下面是一个关于数组的更复杂的例子。 这是一个多维数组 (multi-dimensional Array),或者说是一个包含了其他数组的数组。 可以注意到,在它的内部还包含了 JavaScript 中的对象(objects)结构。 我们会在后面的小节中讨论该数据结构,但现在你只需要知道数组能够存储复杂的对象类型数据。
```js
let complexArray = [
@@ -45,35 +46,35 @@ let complexArray = [
# --instructions--
-We have defined a variable called `yourArray`. Complete the statement by assigning an array of at least 5 elements in length to the `yourArray` variable. Your array should contain at least one string, one number, and one boolean.
+我们已经定义了一个名为 `yourArray` 的变量。 请修改代码,将一个含有至少 5 个元素的数组赋值给 `yourArray` 变量。 你的数组中应包含至少一个 string 类型的数据、一个 number 类型的数据和一个 boolean 类型的数据。
# --hints--
-`yourArray` should be an array.
+`yourArray` 应为数组。
```js
assert.strictEqual(Array.isArray(yourArray), true);
```
-`yourArray` should be at least 5 elements long.
+`yourArray` 应包含至少 5 个元素。
```js
assert.isAtLeast(yourArray.length, 5);
```
-`yourArray` should contain at least one `boolean`.
+`yourArray` 应包含至少一个 `boolean`。
```js
assert(yourArray.filter((el) => typeof el === 'boolean').length >= 1);
```
-`yourArray` should contain at least one `number`.
+`yourArray` 应包含至少一个 `number`。
```js
assert(yourArray.filter((el) => typeof el === 'number').length >= 1);
```
-`yourArray` should contain at least one `string`.
+`yourArray` 应包含至少一个 `string`。
```js
assert(yourArray.filter((el) => typeof el === 'string').length >= 1);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md
index 0a1b708108..cccb75c914 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md
@@ -1,6 +1,6 @@
---
id: 56bbb991ad1ed5201cd392ca
-title: Access Array Data with Indexes
+title: 通过索引访问数组中的数据
challengeType: 1
videoUrl: 'https://scrimba.com/c/cBZQbTz'
forumTopicId: 16158
@@ -9,30 +9,31 @@ dashedName: access-array-data-with-indexes
# --description--
-We can access the data inside arrays using indexes.
+我们可以使用索引(indexes)来访问数组中的数据。
-Array indexes are written in the same bracket notation that strings use, except that instead of specifying a character, they are specifying an entry in the array. Like strings, arrays use zero-based indexing, so the first element in an array has an index of `0`.
+数组索引与字符串一样使用方括号来表示,不同的是,它们不是指定字符,而是指定数组中的一个条目。 数组索引与字符串索引一样是从 0 开始(zero-based)的,所以数组中第一个元素的索引编号是 `0`。
-**Example**
+**示例**
```js
var array = [50,60,70];
-array[0]; // equals 50
-var data = array[1]; // equals 60
+array[0];
+var data = array[1];
```
-**Note**
-There shouldn't be any spaces between the array name and the square brackets, like `array [0]`. Although JavaScript is able to process this correctly, this may confuse other programmers reading your code.
+现在 `array[0]` 的值是 `50`, `data` 的值为 `60`.
+
+**注意:**数组名与方括号之间不应该有任何空格,比如`array [0]` 。 尽管 JavaScript 能够正确处理这种情况,但是当其他程序员阅读你写的代码时,这可能让他们感到困惑。
# --instructions--
-Create a variable called `myData` and set it to equal the first value of `myArray` using bracket notation.
+创建一个名为 `myData` 的变量,使用方括号取出 `myArray` 数组中第一个元素的值并将其赋值给新创建的变量。
# --hints--
-The variable `myData` should equal the first value of `myArray`.
+变量 `myData` 应该等于`myArray` 数组中第一个元素的值。
```js
assert(
@@ -50,7 +51,7 @@ assert(
);
```
-The data in variable `myArray` should be accessed using bracket notation.
+应该使用括号访问变量 `myArray` 中的数据。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/access-multi-dimensional-arrays-with-indexes.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/access-multi-dimensional-arrays-with-indexes.md
index d7ca5ed641..19d1f874d9 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/access-multi-dimensional-arrays-with-indexes.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/access-multi-dimensional-arrays-with-indexes.md
@@ -1,6 +1,6 @@
---
id: 56592a60ddddeae28f7aa8e1
-title: Access Multi-Dimensional Arrays With Indexes
+title: 使用索引访问多维数组
challengeType: 1
videoUrl: 'https://scrimba.com/c/ckND4Cq'
forumTopicId: 16159
@@ -9,9 +9,9 @@ dashedName: access-multi-dimensional-arrays-with-indexes
# --description--
-One way to think of a multi-dimensional array, is as an *array of arrays*. When you use brackets to access your array, the first set of brackets refers to the entries in the outer-most (the first level) array, and each additional pair of brackets refers to the next level of entries inside.
+我们可以把多维数组看作成是*数组中的数组*。 使用方括号表示法访问数组时,第一个方括号访问的是数组的最外层(第一层),第二个方括号访问的是数组的第二层,以此类推。
-**Example**
+**例如:**
```js
var arr = [
@@ -20,27 +20,28 @@ var arr = [
[7,8,9],
[[10,11,12], 13, 14]
];
-arr[3]; // equals [[10,11,12], 13, 14]
-arr[3][0]; // equals [10,11,12]
-arr[3][0][1]; // equals 11
+arr[3];
+arr[3][0];
+arr[3][0][1];
```
-**Note**
-There shouldn't be any spaces between the array name and the square brackets, like `array [0][0]` and even this `array [0] [0]` is not allowed. Although JavaScript is able to process this correctly, this may confuse other programmers reading your code.
+`arr[3]` 为 `[[10, 11, 12], 13, 14]`,`arr[3][0]` 为 `[10, 11, 12]`,并且 `arr[3][0][1]` 为 `11`。
+
+**注意:** 数组名与方括号之间不应该有任何空格,比如`array [0][0]` 甚至是 `array [0] [0]` 都是不允许的。 尽管 JavaScript 能够正确处理这种情况,但是当其他程序员阅读你写的代码时,这可能让他们感到困惑。
# --instructions--
-Using bracket notation select an element from `myArray` such that `myData` is equal to `8`.
+使用方括号从 `myArray` 中选取一个值,使得 `myData` 等于 `8`。
# --hints--
-`myData` should be equal to `8`.
+`myData` 应该等于 `8`。
```js
assert(myData === 8);
```
-You should be using bracket notation to read the correct value from `myArray`.
+你应该使用方括号从 `myArray` 中读取正确的值。
```js
assert(/myData=myArray\[2\]\[1\]/.test(__helpers.removeWhiteSpace(code)));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-arrays.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-arrays.md
index 59d912c1cf..fcc84457c8 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-arrays.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-arrays.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244cd
-title: Accessing Nested Arrays
+title: 访问嵌套数组
challengeType: 1
videoUrl: 'https://scrimba.com/c/cLeGDtZ'
forumTopicId: 16160
@@ -9,9 +9,9 @@ dashedName: accessing-nested-arrays
# --description--
-As we have seen in earlier examples, objects can contain both nested objects and nested arrays. Similar to accessing nested objects, Array bracket notation can be chained to access nested arrays.
+在之前的挑战中,我们学习了在对象中嵌套对象和数组。 与访问嵌套对象类似,数组的方括号可以用来对嵌套数组进行链式访问。
-Here is an example of how to access a nested array:
+下面是访问嵌套数组的例子:
```js
var ourPets = [
@@ -32,23 +32,25 @@ var ourPets = [
]
}
];
-ourPets[0].names[1]; // "Fluffy"
-ourPets[1].names[0]; // "Spot"
+ourPets[0].names[1];
+ourPets[1].names[0];
```
+`ourPets[0].names[1]` 应该是字符串 `Fluffy`, 并且 `ourPets[1].names[0]` 应该是字符串 `Spot`。
+
# --instructions--
-Retrieve the second tree from the variable `myPlants` using object dot and array bracket notation.
+使用对象的点号和数组的方括号从变量 `myPlants` 检索出第二棵树。
# --hints--
-`secondTree` should equal "pine".
+`secondTree` 应该等于字符串 `pine`。
```js
assert(secondTree === 'pine');
```
-Your code should use dot and bracket notation to access `myPlants`.
+你的代码应该使用点号和方括号访问 `myPlants`。
```js
assert(/=\s*myPlants\[1\].list\[1\]/.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-objects.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-objects.md
index d8a7470d1f..db833dd81b 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-objects.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-nested-objects.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244cc
-title: Accessing Nested Objects
+title: 访问嵌套对象
challengeType: 1
videoUrl: 'https://scrimba.com/c/cRnRnfa'
forumTopicId: 16161
@@ -9,9 +9,9 @@ dashedName: accessing-nested-objects
# --description--
-The sub-properties of objects can be accessed by chaining together the dot or bracket notation.
+我们可以通过连续使用点号表示法和方括号表示法来访问对象的嵌套属性。
-Here is a nested object:
+这是一个嵌套对象:
```js
var ourStorage = {
@@ -26,23 +26,25 @@ var ourStorage = {
"bottom drawer": "soda"
}
};
-ourStorage.cabinet["top drawer"].folder2; // "secrets"
-ourStorage.desk.drawer; // "stapler"
+ourStorage.cabinet["top drawer"].folder2;
+ourStorage.desk.drawer;
```
+`ourStorage.cabinet["top drawer"].folder2` 将会是字符串 `secrets`,并且 `ourStorage.desk.drawer` 将会是字符串 `stapler`。
+
# --instructions--
-Access the `myStorage` object and assign the contents of the `glove box` property to the `gloveBoxContents` variable. Use dot notation for all properties where possible, otherwise use bracket notation.
+访问 `myStorage` 对象并将 `glove box` 属性的内容赋值给 `gloveBoxContents` 变量。 在可能的情况下,对所有的属性使用点号,否则使用方括号。
# --hints--
-`gloveBoxContents` should equal "maps".
+`gloveBoxContents` 应该等于字符串 `maps`。
```js
assert(gloveBoxContents === 'maps');
```
-Your code should use dot and bracket notation to access `myStorage`.
+你的代码应该使用点号和方括号来访问 `myStorage`。
```js
assert(/=\s*myStorage\.car\.inside\[\s*("|')glove box\1\s*\]/g.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-bracket-notation.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-bracket-notation.md
index a92f2eddcd..db05692570 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-bracket-notation.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-bracket-notation.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244c8
-title: Accessing Object Properties with Bracket Notation
+title: 使用方括号表示法访问对象属性
challengeType: 1
videoUrl: 'https://scrimba.com/c/cBvmEHP'
forumTopicId: 16163
@@ -9,11 +9,11 @@ dashedName: accessing-object-properties-with-bracket-notation
# --description--
-The second way to access the properties of an object is bracket notation (`[]`). If the property of the object you are trying to access has a space in its name, you will need to use bracket notation.
+访问对象属性的第二种方式是方括号表示法(`[]`)。 如果你想访问的属性名中包含空格,就必须使用方括号表示法来获取它的属性值。
-However, you can still use bracket notation on object properties without spaces.
+当然,如果属性名不包含空格,也可以使用方括号表示法。
-Here is a sample of using bracket notation to read an object's property:
+这是一个使用方括号表示法读取对象属性的例子:
```js
var myObj = {
@@ -21,44 +21,46 @@ var myObj = {
"More Space": "Spock",
"NoSpace": "USS Enterprise"
};
-myObj["Space Name"]; // Kirk
-myObj['More Space']; // Spock
-myObj["NoSpace"]; // USS Enterprise
+myObj["Space Name"];
+myObj['More Space'];
+myObj["NoSpace"];
```
-Note that property names with spaces in them must be in quotes (single or double).
+`myObj["Space Name"]` 将会是字符串 `Kirk`,`myObj['More Space']` 将会是字符串 `Spock`,并且`myObj["NoSpace"]` 将会是字符串 `USS Enterprise`。
+
+注意,如果属性名中包含空格,就必须使用引号(单引号或双引号)将它们包裹起来。
# --instructions--
-Read the values of the properties `"an entree"` and `"the drink"` of `testObj` using bracket notation and assign them to `entreeValue` and `drinkValue` respectively.
+使用方括号读取 `testObj` 中 `an entree` 和 `the drink` 的属性值,并分别将它们赋值给 `entreeValue` 和 `drinkValue`。
# --hints--
-`entreeValue` should be a string
+`entreeValue` 应该是一个字符串。
```js
assert(typeof entreeValue === 'string');
```
-The value of `entreeValue` should be `"hamburger"`
+`entreeValue` 的值应该为字符串 `hamburger`
```js
assert(entreeValue === 'hamburger');
```
-`drinkValue` should be a string
+`drinkValue` 应该是一个字符串
```js
assert(typeof drinkValue === 'string');
```
-The value of `drinkValue` should be `"water"`
+`drinkValue` 的值应该为字符串 `water`
```js
assert(drinkValue === 'water');
```
-You should use bracket notation twice
+你应该使用两次方括号
```js
assert(code.match(/testObj\s*?\[('|")[^'"]+\1\]/g).length > 1);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-dot-notation.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-dot-notation.md
index af90aafcbc..d5663a178b 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-dot-notation.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-dot-notation.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244c7
-title: Accessing Object Properties with Dot Notation
+title: 通过点号表示法访问对象属性
challengeType: 1
videoUrl: 'https://scrimba.com/c/cGryJs8'
forumTopicId: 16164
@@ -9,52 +9,53 @@ dashedName: accessing-object-properties-with-dot-notation
# --description--
-There are two ways to access the properties of an object: dot notation (`.`) and bracket notation (`[]`), similar to an array.
+和访问数组类似,访问对象属性有两种方式:点号表示法(`.`)和方括号表示法(`[]`)。
-Dot notation is what you use when you know the name of the property you're trying to access ahead of time.
+如果我们已经提前知道要访问的属性名,使用点号表示法是最方便的。
-Here is a sample of using dot notation (`.`) to read an object's property:
+这里是一个用点符号(`.`)读取对象属性的示例:
```js
var myObj = {
prop1: "val1",
prop2: "val2"
};
-var prop1val = myObj.prop1; // val1
-var prop2val = myObj.prop2; // val2
+var prop1val = myObj.prop1;
+var prop2val = myObj.prop2;
```
+`prop1val` 的值将为字符串 `val1`,并且`prop2val` 的值将为字符串 `val2`。
# --instructions--
-Read in the property values of `testObj` using dot notation. Set the variable `hatValue` equal to the object's property `hat` and set the variable `shirtValue` equal to the object's property `shirt`.
+使用点号读取 `testObj` 的属性值。 将变量 `hatValue` 的值设置为该对象的 `hat` 属性的值,并将变量 `shirtValue` 的值设置为该对象的 `shirt` 属性的值。
# --hints--
-`hatValue` should be a string
+`hatValue` 应该是一个字符串
```js
assert(typeof hatValue === 'string');
```
-The value of `hatValue` should be `"ballcap"`
+`hatValue` 的值应该为字符串 `ballcap`
```js
assert(hatValue === 'ballcap');
```
-`shirtValue` should be a string
+`shirtValue` 应该是一个字符串
```js
assert(typeof shirtValue === 'string');
```
-The value of `shirtValue` should be `"jersey"`
+`shirtValue` 的值应该为字符串 `jersey`
```js
assert(shirtValue === 'jersey');
```
-You should use dot notation twice
+你应该使用两个点号
```js
assert(code.match(/testObj\.\w+/g).length > 1);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-variables.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-variables.md
index 05713220d6..728d5170ac 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-variables.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-variables.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244c9
-title: Accessing Object Properties with Variables
+title: 通过变量访问对象属性
challengeType: 1
videoUrl: 'https://scrimba.com/c/cnQyKur'
forumTopicId: 16165
@@ -9,9 +9,9 @@ dashedName: accessing-object-properties-with-variables
# --description--
-Another use of bracket notation on objects is to access a property which is stored as the value of a variable. This can be very useful for iterating through an object's properties or when accessing a lookup table.
+对对象上使用方括号表示法,还可以访问对象上作为变量值存储的属性。 当你需要遍历对象的所有属性,或者根据一个变量的值查找对应的属性值时,这种写法尤其适用。
-Here is an example of using a variable to access a property:
+以下是一个使用变量来访问属性的例子:
```js
var dogs = {
@@ -19,10 +19,12 @@ var dogs = {
};
var myDog = "Hunter";
var myBreed = dogs[myDog];
-console.log(myBreed); // "Doberman"
+console.log(myBreed);
```
-Another way you can use this concept is when the property's name is collected dynamically during the program execution, as follows:
+字符串 `Doberman` 将会出现在控制台中。
+
+使用这一概念的另一种情况是:属性的名字是在程序运行期间动态收集得到的。如下所示:
```js
var someObj = {
@@ -32,49 +34,51 @@ function propPrefix(str) {
var s = "prop";
return s + str;
}
-var someProp = propPrefix("Name"); // someProp now holds the value 'propName'
-console.log(someObj[someProp]); // "John"
+var someProp = propPrefix("Name");
+console.log(someObj[someProp]);
```
-Note that we do *not* use quotes around the variable name when using it to access the property because we are using the *value* of the variable, not the *name*.
+`someProp` 的值将为字符串 `propName`,并且字符串 `John` 将会出现在控制台中。
+
+注意,当使用变量名访问属性时,我们*没有*使用引号包裹它,因为我们正在使用的是变量的*值*,而不是变量的*名字*。
# --instructions--
-Set the `playerNumber` variable to `16`. Then, use the variable to look up the player's name and assign it to `player`.
+将变量 `playerNumber` 设置为 `16`。 然后,使用该变量查找玩家的名字,并将其赋值给`player`。
# --hints--
-`playerNumber` should be a number
+`playerNumber` 应该是一个数字
```js
assert(typeof playerNumber === 'number');
```
-The variable `player` should be a string
+变量 `player` 应该是一个字符串
```js
assert(typeof player === 'string');
```
-The value of `player` should be "Montana"
+`player` 的值应该为字符串 `Montana`
```js
assert(player === 'Montana');
```
-You should use bracket notation to access `testObj`
+你应该使用方括号访问 `testObj`
```js
assert(/testObj\s*?\[.*?\]/.test(code));
```
-You should not assign the value `Montana` to the variable `player` directly.
+你不应该直接将值 `Montana` 赋给变量 `player`。
```js
assert(!code.match(/player\s*=\s*"|\'\s*Montana\s*"|\'\s*;/gi));
```
-You should be using the variable `playerNumber` in your bracket notation
+你应该在你的方括号内使用变量 `playerNumber`。
```js
assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md
index 975b0206be..9a94ced3b1 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/add-new-properties-to-a-javascript-object.md
@@ -1,6 +1,6 @@
---
id: 56bbb991ad1ed5201cd392d2
-title: Add New Properties to a JavaScript Object
+title: 给 JavaScript 对象添加新属性
challengeType: 1
videoUrl: 'https://scrimba.com/c/cQe38UD'
forumTopicId: 301169
@@ -9,19 +9,19 @@ dashedName: add-new-properties-to-a-javascript-object
# --description--
-You can add new properties to existing JavaScript objects the same way you would modify them.
+你也可以像更改属性一样给 JavaScript 对象添加属性。
-Here's how we would add a `"bark"` property to `ourDog`:
+这里展示了如何给 `ourDog` 添加一个属性 `bark`:
`ourDog.bark = "bow-wow";`
-or
+或者
`ourDog["bark"] = "bow-wow";`
-Now when we evaluate `ourDog.bark`, we'll get his bark, "bow-wow".
+现在,当我们执行 `ourDog.bark` 时,我们就能得到他的叫声,`bow-wow`。
-Example:
+例如:
```js
var ourDog = {
@@ -36,17 +36,17 @@ ourDog.bark = "bow-wow";
# --instructions--
-Add a `"bark"` property to `myDog` and set it to a dog sound, such as "woof". You may use either dot or bracket notation.
+给 `myDog` 添加一个属性 `bark` ,并将其设置为狗的声音,比如“woof“. 你可以使用点号表示法或方括号表示法来完成此挑战。
# --hints--
-You should add the property `"bark"` to `myDog`.
+你应该将属性 `bark` 添加到 `myDog`。
```js
assert(myDog.bark !== undefined);
```
-You should not add `"bark"` to the setup section.
+你不应该在 Setup 部分添加 `bark`。
```js
assert(!/bark[^\n]:/.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/add-two-numbers-with-javascript.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/add-two-numbers-with-javascript.md
index 255cd3a3ed..af90b54023 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/add-two-numbers-with-javascript.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/add-two-numbers-with-javascript.md
@@ -1,6 +1,6 @@
---
id: cf1111c1c11feddfaeb3bdef
-title: Add Two Numbers with JavaScript
+title: 加法运算
challengeType: 1
videoUrl: 'https://scrimba.com/c/cM2KBAG'
forumTopicId: 16650
@@ -9,31 +9,33 @@ dashedName: add-two-numbers-with-javascript
# --description--
-`Number` is a data type in JavaScript which represents numeric data.
+`Number` 是 JavaScript 中的一种数据类型,用来表示数值。
-Now let's try to add two numbers using JavaScript.
+现在我们来尝试在 JavaScript 中做加法运算。
-JavaScript uses the `+` symbol as an addition operator when placed between two numbers.
+JavaScript 中,我们通过符号 `+` 来进行加法运算。
-**Example:**
+**代码示例:**
```js
-myVar = 5 + 10; // assigned 15
+myVar = 5 + 10;
```
+现在,变量 `myVar` 的值为 `15`。
+
# --instructions--
-Change the `0` so that sum will equal `20`.
+请改变数字 `0` 让变量 sum 的值为 `20`。
# --hints--
-`sum` should equal `20`.
+`sum` 的值应该等于 `20`。
```js
assert(sum === 20);
```
-You should use the `+` operator.
+请使用 `+` 运算符。
```js
assert(/\+/.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements.md
index 51b62017b0..98dba35fbd 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/adding-a-default-option-in-switch-statements.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244de
-title: Adding a Default Option in Switch Statements
+title: 在 switch 语句中添加默认选项
challengeType: 1
videoUrl: 'https://scrimba.com/c/c3JvVfg'
forumTopicId: 16653
@@ -9,9 +9,9 @@ dashedName: adding-a-default-option-in-switch-statements
# --description--
-In a `switch` statement you may not be able to specify all possible values as `case` statements. Instead, you can add the `default` statement which will be executed if no matching `case` statements are found. Think of it like the final `else` statement in an `if/else` chain.
+在 `switch` 语句中,你可能无法用 `case` 枚举出所有可能的值。 相反,你可以添加 `default` 语句,它会在找不到相匹配的 `case` 语句之后执行。 你可以把它看作是 `if/else` 链中最后的那个 `else` 语句。
-A `default` statement should be the last case.
+`default` 语句应该被放到最后。
```js
switch (num) {
@@ -30,57 +30,57 @@ switch (num) {
# --instructions--
-Write a switch statement to set `answer` for the following conditions:
-`"a"` - "apple"
-`"b"` - "bird"
-`"c"` - "cat"
-`default` - "stuff"
+写一个 switch 语句,设置以下条件设置 `answer`:
+`a` - `apple`
+`b` - `bird`
+`c` - `cat`
+`default` - `stuff`
# --hints--
-`switchOfStuff("a")` should have a value of "apple"
+`switchOfStuff("a")` 应该返回字符串 `apple`
```js
assert(switchOfStuff('a') === 'apple');
```
-`switchOfStuff("b")` should have a value of "bird"
+`switchOfStuff("b")` 应该返回字符串 `bird`
```js
assert(switchOfStuff('b') === 'bird');
```
-`switchOfStuff("c")` should have a value of "cat"
+`switchOfStuff("c")` 应该返回字符串 `cat`
```js
assert(switchOfStuff('c') === 'cat');
```
-`switchOfStuff("d")` should have a value of "stuff"
+`switchOfStuff("d")` 应该返回字符串 `stuff`
```js
assert(switchOfStuff('d') === 'stuff');
```
-`switchOfStuff(4)` should have a value of "stuff"
+`switchOfStuff(4)` 应该返回字符串 `stuff`
```js
assert(switchOfStuff(4) === 'stuff');
```
-You should not use any `if` or `else` statements
+不能使用 `if` 或 `else` 语句。
```js
assert(!/else/g.test(code) || !/if/g.test(code));
```
-You should use a `default` statement
+你应该使用 `default` 语句。
```js
assert(switchOfStuff('string-to-trigger-default-case') === 'stuff');
```
-You should have at least 3 `break` statements
+你至少应该写 3 个 `break` 语句。
```js
assert(code.match(/break/g).length > 2);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings.md
index be826ab034..0795af9b46 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/appending-variables-to-strings.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244ed
-title: Appending Variables to Strings
+title: 将变量追加到字符串
challengeType: 1
videoUrl: 'https://scrimba.com/c/cbQmZfa'
forumTopicId: 16656
@@ -9,30 +9,31 @@ dashedName: appending-variables-to-strings
# --description--
-Just as we can build a string over multiple lines out of string literals, we can also append variables to a string using the plus equals (`+=`) operator.
+就像我们可以用多行字符串字面量构建单个字符串一样,我们还可以使用加且赋值(`+=`)运算符将字符串追加到字符串的末尾。
-Example:
+示例:
```js
var anAdjective = "awesome!";
var ourStr = "freeCodeCamp is ";
ourStr += anAdjective;
-// ourStr is now "freeCodeCamp is awesome!"
```
+`ourStr` 值为 `freeCodeCamp is awesome!`。
+
# --instructions--
-Set `someAdjective` to a string of at least 3 characters and append it to `myStr` using the `+=` operator.
+将 `someAdjective` 设置为一个至少包含 3 个字符的字符串,然后使用 `+=` 运算符将它追加到 `myStr`。
# --hints--
-`someAdjective` should be set to a string at least 3 characters long.
+`someAdjective` 应当为包含至少三个字符的字符串。
```js
assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);
```
-You should append `someAdjective` to `myStr` using the `+=` operator.
+你应该使用 `+=` 运算符将 `someAdjective` 追加到 `myStr`。
```js
assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/assigning-the-value-of-one-variable-to-another.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/assigning-the-value-of-one-variable-to-another.md
index 2938f087ee..1a756600d9 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/assigning-the-value-of-one-variable-to-another.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/assigning-the-value-of-one-variable-to-another.md
@@ -1,6 +1,6 @@
---
id: 5ee127a03c3b35dd45426493
-title: Assigning the Value of One Variable to Another
+title: 将一个变量的值赋给另一个
challengeType: 1
videoUrl: ''
forumTopicId: 418265
@@ -9,7 +9,7 @@ dashedName: assigning-the-value-of-one-variable-to-another
# --description--
-After a value is assigned to a variable using the assignment operator, you can assign the value of that variable to another variable using the assignment operator.
+在使用赋值运算符赋予变量某个值后,你可以使用赋值运算符将该变量的值赋给另一个变量。
```js
var myVar;
@@ -18,27 +18,27 @@ var myNum;
myNum = myVar;
```
-The above declares a `myVar` variable with no value, then assigns it the value `5`. Next, a variable named `myNum` is declared with no value. Then, the contents of `myVar` (which is `5`) is assigned to the variable `myNum`. Now, `myNum` also has the value of `5`.
+以上代码声明了一个没有初始值的变量 `myVar`,然后给它赋值为 `5`。 紧接着,又声明了一个没有初始值的变量 `myNum`。 然后,变量 `myVar` 的内容(也就是 `5`)被赋给了变量 `myNum`。 现在,变量 `myNum` 的值也为 `5`。
# --instructions--
-Assign the contents of `a` to variable `b`.
+把变量 `a` 的内容赋给变量 `b`。
# --hints--
-You should not change code above the specified comment.
+你不应该修改注释上面的代码。
```js
assert(/var a;/.test(code) && /a = 7;/.test(code) && /var b;/.test(code));
```
-`b` should have a value of 7.
+`b` 的值应该为 `7`。
```js
assert(typeof b === 'number' && b === 7);
```
-`a` should be assigned to `b` with `=`.
+应该使用 `=` 将 `a` 赋给 `b`。
```js
assert(/b\s*=\s*a\s*/g.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/build-javascript-objects.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/build-javascript-objects.md
index 9289d9ff58..4ecd72ba0e 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/build-javascript-objects.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/build-javascript-objects.md
@@ -1,6 +1,6 @@
---
id: 56bbb991ad1ed5201cd392d0
-title: Build JavaScript Objects
+title: 创建 JavaScript 对象
challengeType: 1
videoUrl: 'https://scrimba.com/c/cWGkbtd'
forumTopicId: 16769
@@ -9,13 +9,13 @@ dashedName: build-javascript-objects
# --description--
-You may have heard the term `object` before.
+你之前可能听过 `object` 这个词。
-Objects are similar to `arrays`, except that instead of using indexes to access and modify their data, you access the data in objects through what are called `properties`.
+对象和 `arrays` 类似,区别在于数组使用索引来访问和修改数据,而对象中的数据是通过 `properties` 访问的。
-Objects are useful for storing data in a structured way, and can represent real world objects, like a cat.
+对象非常适合用来存储结构化数据,可以表示真实世界中的物体,比如一只猫。
-Here's a sample cat object:
+这里是一个猫对象的样本:
```js
var cat = {
@@ -26,7 +26,7 @@ var cat = {
};
```
-In this example, all the properties are stored as strings, such as - `"name"`, `"legs"`, and `"tails"`. However, you can also use numbers as properties. You can even omit the quotes for single-word string properties, as follows:
+在这个示例中,所有的属性都被纯属为字符串,比如 `name`、`legs` 和 `tails`。 然而,你也可以使用数字作为属性。 你甚至可以省略单字字符串属性中的引号,如下所示:
```js
var anotherObject = {
@@ -36,17 +36,17 @@ var anotherObject = {
};
```
-However, if your object has any non-string properties, JavaScript will automatically typecast them as strings.
+然而,如果你的对象有非字符串属性的话,JavaScript 会自动将它们转为字符串。
# --instructions--
-Make an object that represents a dog called `myDog` which contains the properties `"name"` (a string), `"legs"`, `"tails"` and `"friends"`.
+确保对象表示一只名为 `myDog` 的狗,包含属性 `name`(字符串)、`legs`、`tails` 和 `friends`。
-You can set these object properties to whatever values you want, as long as `"name"` is a string, `"legs"` and `"tails"` are numbers, and `"friends"` is an array.
+你可以随意设置这些对象的属性值,只要 `name` 是字符串,`legs` 和 `tails` 是数字,`friends` 是数组即可。
# --hints--
-`myDog` should contain the property `name` and it should be a `string`.
+`myDog` 应该包含 `name` 属性,并且它应该是一个 `string`。
```js
assert(
@@ -64,7 +64,7 @@ assert(
);
```
-`myDog` should contain the property `legs` and it should be a `number`.
+`myDog`应该包含 `legs` 属性,并且它应该是一个 `number`。
```js
assert(
@@ -82,7 +82,7 @@ assert(
);
```
-`myDog` should contain the property `tails` and it should be a `number`.
+`myDog` 应该包含 `tails` 属性,并且它应该是一个 `number`。
```js
assert(
@@ -100,7 +100,7 @@ assert(
);
```
-`myDog` should contain the property `friends` and it should be an `array`.
+`myDog` 应该包含 `friends` 属性,并且它应该是一个 `array`。
```js
assert(
@@ -118,7 +118,7 @@ assert(
);
```
-`myDog` should only contain all the given properties.
+`myDog` 只应该包含所有给定的属性。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/chaining-if-else-statements.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/chaining-if-else-statements.md
index f68a2f94db..343184029d 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/chaining-if-else-statements.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/chaining-if-else-statements.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244dc
-title: Chaining If Else Statements
+title: 多个 if else 语句
challengeType: 1
videoUrl: 'https://scrimba.com/c/caeJgsw'
forumTopicId: 16772
@@ -9,7 +9,7 @@ dashedName: chaining-if-else-statements
# --description--
-`if/else` statements can be chained together for complex logic. Here is pseudocode of multiple chained `if` / `else if` statements:
+`if/else` 语句串联在一起可以实现复杂的逻辑。 这是多个 `if` / `else if` 语句串联在一起的伪代码:
```js
if (condition1) {
@@ -26,89 +26,89 @@ if (condition1) {
# --instructions--
-Write chained `if`/`else if` statements to fulfill the following conditions:
+请将 `if`/`else if` 语句串联起来,实现下面的逻辑:
-`num < 5` - return "Tiny"
-`num < 10` - return "Small"
-`num < 15` - return "Medium"
-`num < 20` - return "Large"
-`num >= 20` - return "Huge"
+`num < 5` - 返回 `Tiny`
+`num < 10` - 返回 `Small`
+`num < 15` - 返回 `Medium`
+`num < 20` - 返回 `Large`
+`num >= 20` - 返回 `Huge`
# --hints--
-You should have at least four `else` statements
+应至少有 4 个 `else` 语句。
```js
assert(code.match(/else/g).length > 3);
```
-You should have at least four `if` statements
+应至少有 4 个 `if` 语句。
```js
assert(code.match(/if/g).length > 3);
```
-You should have at least one `return` statement
+应至少有 1 个 `return` 语句。
```js
assert(code.match(/return/g).length >= 1);
```
-`testSize(0)` should return "Tiny"
+`testSize(0)` 应该返回字符串 `Tiny`
```js
assert(testSize(0) === 'Tiny');
```
-`testSize(4)` should return "Tiny"
+`testSize(4)` 应该返回字符串 `Tiny`
```js
assert(testSize(4) === 'Tiny');
```
-`testSize(5)` should return "Small"
+`testSize(5)` 应该返回字符串 `Small`
```js
assert(testSize(5) === 'Small');
```
-`testSize(8)` should return "Small"
+`testSize(8)` 应该返回字符串 `Small`
```js
assert(testSize(8) === 'Small');
```
-`testSize(10)` should return "Medium"
+`testSize(10)` 应该返回字符串 `Medium`
```js
assert(testSize(10) === 'Medium');
```
-`testSize(14)` should return "Medium"
+`testSize(14)` 应该返回字符串 `Medium`
```js
assert(testSize(14) === 'Medium');
```
-`testSize(15)` should return "Large"
+`testSize(15)` 应该返回字符串 `Large`
```js
assert(testSize(15) === 'Large');
```
-`testSize(17)` should return "Large"
+`testSize(17)` 应该返回字符串 `Large`
```js
assert(testSize(17) === 'Large');
```
-`testSize(20)` should return "Huge"
+`testSize(20)` 应该返回字符串 `Huge`
```js
assert(testSize(20) === 'Huge');
```
-`testSize(25)` should return "Huge"
+`testSize(25)` 应该返回字符串 `Huge`
```js
assert(testSize(25) === 'Huge');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code.md
index e828a1ba0e..50271224d6 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code.md
@@ -1,6 +1,6 @@
---
id: bd7123c9c441eddfaeb4bdef
-title: Comment Your JavaScript Code
+title: 给代码添加注释
challengeType: 1
videoUrl: 'https://scrimba.com/c/c7ynnTp'
forumTopicId: 16783
@@ -9,39 +9,38 @@ dashedName: comment-your-javascript-code
# --description--
-Comments are lines of code that JavaScript will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.
+被注释的代码块在 JavaScript 之中是不会执行的。 在代码中写注释,是一个可以让你自己和以后的其他人理解代码作用的好方法。
-There are two ways to write comments in JavaScript:
+JavaScript有两种写注释的方法。
-Using `//` will tell JavaScript to ignore the remainder of the text on the current line:
+使用 `//` 注释掉当前行的代码。 这是一个行内注释:
```js
// This is an in-line comment.
```
-You can make a multi-line comment beginning with `/*` and ending with `*/`:
+你也可以使用多行注释来注释你的代码,使用 `/*` 开始, `*/` 结束. 这是一个多行注释:
```js
/* This is a
multi-line comment */
```
-**Best Practice**
-As you write code, you should regularly add comments to clarify the function of parts of your code. Good commenting can help communicate the intent of your code—both for others *and* for your future self.
+**最佳实践**当你写代码的时候,你应该时不时的添加注释来解释你写的代码的作用。 适当的注释能让别人*和*你未来的自己更容易看懂代码。
# --instructions--
-Try creating one of each type of comment.
+尝试创建这两种类型的注释。
# --hints--
-You should create a `//` style comment that contains at least five letters.
+创建一个 `//` 样式的注释,被注释的文本至少要包含 5 个字符。
```js
assert(code.match(/(\/\/)...../g));
```
-You should create a `/* */` style comment that contains at least five letters.
+创建一个 `/* */` 样式的注释,被注释的文本至少要包含 5 个字符。
```js
assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm));
@@ -50,7 +49,9 @@ assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm));
# --seed--
## --seed-contents--
+
```js
+
```
# --solutions--
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator.md
index 8fd2086992..8e15f96ca2 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244d0
-title: Comparison with the Equality Operator
+title: 相等运算符
challengeType: 1
videoUrl: 'https://scrimba.com/c/cKyVMAL'
forumTopicId: 16784
@@ -9,9 +9,9 @@ dashedName: comparison-with-the-equality-operator
# --description--
-There are many comparison operators in JavaScript. All of these operators return a boolean `true` or `false` value.
+在 JavaScript 中,有很多 相互比较的操作。 所有这些操作符都返回一个 `true` 或 `false` 值。
-The most basic operator is the equality operator `==`. The equality operator compares two values and returns `true` if they're equivalent or `false` if they are not. Note that equality is different from assignment (`=`), which assigns the value on the right of the operator to a variable on the left.
+最基本的运算符是相等运算符:`==`。 相等运算符比较两个值,如果它们是相等,返回 `true`,如果它们不相等,返回 `false`。 值得注意的是相等运算符不同于赋值运算符(`=`),赋值运算符是把等号右边的值赋给左边的变量。
```js
function equalityTest(myVal) {
@@ -22,40 +22,42 @@ function equalityTest(myVal) {
}
```
-If `myVal` is equal to `10`, the equality operator returns `true`, so the code in the curly braces will execute, and the function will return `"Equal"`. Otherwise, the function will return `"Not Equal"`. In order for JavaScript to compare two different data types (for example, `numbers` and `strings`), it must convert one type to another. This is known as "Type Coercion". Once it does, however, it can compare terms as follows:
+如果 `myVal` 等于 `10`,相等运算符会返回 `true`,因此大括号里面的代码会被执行,函数将返回 `Equal`。 否则,函数返回 `Not Equal`。 在 JavaScript 中,为了让两个不同的数据类型(例如 `numbers` 和 `strings`)的值可以作比较,它必须把一种类型转换为另一种类型。 这叫作 “类型强制转换”。 转换之后,可以像下面这样来比较:
```js
-1 == 1 // true
-1 == 2 // false
-1 == '1' // true
-"3" == 3 // true
+1 == 1
+1 == 2
+1 == '1'
+"3" == 3
```
+按顺序,这些表达式会返回 `true`、`false`、`true`、`true`。
+
# --instructions--
-Add the equality operator to the indicated line so that the function will return "Equal" when `val` is equivalent to `12`.
+把相等运算符添加到指定的行,这样当 `val` 的值为 `12` 的时候,函数会返回 `Equal`。
# --hints--
-`testEqual(10)` should return "Not Equal"
+`testEqual(10)` 应该返回字符串 `Not Equal`
```js
assert(testEqual(10) === 'Not Equal');
```
-`testEqual(12)` should return "Equal"
+`testEqual(12)` 应该返回字符串 `Equal`
```js
assert(testEqual(12) === 'Equal');
```
-`testEqual("12")` should return "Equal"
+`testEqual("12")` 应该返回字符串 `Equal`
```js
assert(testEqual('12') === 'Equal');
```
-You should use the `==` operator
+应该使用 `==` 运算符。
```js
assert(code.match(/==/g) && !code.match(/===/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.md
index 0cb1d1d46a..739ac0a38c 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244d5
-title: Comparison with the Greater Than Or Equal To Operator
+title: 大于或等于运算符
challengeType: 1
videoUrl: 'https://scrimba.com/c/c6KBqtV'
forumTopicId: 16785
@@ -9,68 +9,70 @@ dashedName: comparison-with-the-greater-than-or-equal-to-operator
# --description--
-The greater than or equal to operator (`>=`) compares the values of two numbers. If the number to the left is greater than or equal to the number to the right, it returns `true`. Otherwise, it returns `false`.
+使用大于等于运算符(`>=`)来比较两个数字的大小。 如果大于等于运算符左边的数字比右边的数字大或者相等,会返回 `true`。 否则,会返回 `false`。
-Like the equality operator, `greater than or equal to` operator will convert data types while comparing.
+与相等运算符相似,大于等于运算符在比较的时候会转换值的数据类型。
-**Examples**
+**例如:**
```js
-6 >= 6 // true
-7 >= '3' // true
-2 >= 3 // false
-'7' >= 9 // false
+6 >= 6
+7 >= '3'
+2 >= 3
+'7' >= 9
```
+按顺序,这些表达式会返回 `true`、`true`、`false` 和 `false`。
+
# --instructions--
-Add the greater than or equal to operator to the indicated lines so that the return statements make sense.
+添加大于等于运算符到指定行,使得函数的返回语句有意义。
# --hints--
-`testGreaterOrEqual(0)` should return "Less than 10"
+`testGreaterOrEqual(0)` 应该返回字符串 `Less than 10`。
```js
assert(testGreaterOrEqual(0) === 'Less than 10');
```
-`testGreaterOrEqual(9)` should return "Less than 10"
+`testGreaterOrEqual(9)` 应该返回字符串 `Less than 10`。
```js
assert(testGreaterOrEqual(9) === 'Less than 10');
```
-`testGreaterOrEqual(10)` should return "10 or Over"
+`testGreaterOrEqual(10)` 应该返回字符串 `10 or Over`。
```js
assert(testGreaterOrEqual(10) === '10 or Over');
```
-`testGreaterOrEqual(11)` should return "10 or Over"
+`testGreaterOrEqual(11)` 应该返回字符串 `10 or Over`。
```js
assert(testGreaterOrEqual(11) === '10 or Over');
```
-`testGreaterOrEqual(19)` should return "10 or Over"
+`testGreaterOrEqual(19)` 应该返回字符串 `10 or Over`。
```js
assert(testGreaterOrEqual(19) === '10 or Over');
```
-`testGreaterOrEqual(100)` should return "20 or Over"
+`testGreaterOrEqual(100)` 应该返回字符串 `20 or Over`。
```js
assert(testGreaterOrEqual(100) === '20 or Over');
```
-`testGreaterOrEqual(21)` should return "20 or Over"
+`testGreaterOrEqual(21)` 应该返回字符串 `20 or Over`。
```js
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);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-inequality-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-inequality-operator.md
index 24d6c5fbec..e289c41a8c 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-inequality-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-inequality-operator.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244d2
-title: Comparison with the Inequality Operator
+title: 不等运算符
challengeType: 1
videoUrl: 'https://scrimba.com/c/cdBm9Sr'
forumTopicId: 16787
@@ -9,55 +9,57 @@ dashedName: comparison-with-the-inequality-operator
# --description--
-The inequality operator (`!=`) is the opposite of the equality operator. It means "Not Equal" and returns `false` where equality would return `true` and *vice versa*. Like the equality operator, the inequality operator will convert data types of values while comparing.
+不相等运算符(`!=`)与相等运算符是相反的。 这意味着严格不相等并返回 `false` 的地方,用严格相等运算符会返回 `true`,*反之亦然*。 与相等运算符类似,不相等运算符在比较的时候也会转换值的数据类型。
-**Examples**
+**例如**
```js
-1 != 2 // true
-1 != "1" // false
-1 != '1' // false
-1 != true // false
-0 != false // false
+1 != 2
+1 != "1"
+1 != '1'
+1 != true
+0 != false
```
+按顺序,这些表达式会返回 `true`、`false`、`false`、`false` 和 `false`。
+
# --instructions--
-Add the inequality operator `!=` in the `if` statement so that the function will return "Not Equal" when `val` is not equivalent to `99`
+在 `if` 语句中,添加不相等运算符 `!=`,这样函数在当 `val` 不等于 `99` 的时候,会返回 `Not Equal`。
# --hints--
-`testNotEqual(99)` should return "Equal"
+`testNotEqual(99)` 应该返回字符串 `Equal`
```js
assert(testNotEqual(99) === 'Equal');
```
-`testNotEqual("99")` should return "Equal"
+`testNotEqual("99")` 应该返回字符串 `Equal`
```js
assert(testNotEqual('99') === 'Equal');
```
-`testNotEqual(12)` should return "Not Equal"
+`testNotEqual(12)` 应该返回字符串 `Not Equal`
```js
assert(testNotEqual(12) === 'Not Equal');
```
-`testNotEqual("12")` should return "Not Equal"
+`testNotEqual("12")` 应该返回字符串 `Not Equal`
```js
assert(testNotEqual('12') === 'Not Equal');
```
-`testNotEqual("bob")` should return "Not Equal"
+`testNotEqual("bob")` 应该返回字符串 `Not Equal`
```js
assert(testNotEqual('bob') === 'Not Equal');
```
-You should use the `!=` operator
+你应该使用 `!=` 运算符。
```js
assert(code.match(/(?!!==)!=/));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-or-equal-to-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-or-equal-to-operator.md
index 5174b635b4..f8c13e4626 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-or-equal-to-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-or-equal-to-operator.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244d7
-title: Comparison with the Less Than Or Equal To Operator
+title: 小于或等于运算符
challengeType: 1
videoUrl: 'https://scrimba.com/c/cNVR7Am'
forumTopicId: 16788
@@ -9,67 +9,69 @@ dashedName: comparison-with-the-less-than-or-equal-to-operator
# --description--
-The less than or equal to operator (`<=`) compares the values of two numbers. If the number to the left is less than or equal to the number to the right, it returns `true`. If the number on the left is greater than the number on the right, it returns `false`. Like the equality operator, `less than or equal to` converts data types.
+使用小于等于运算符(`<=`)比较两个数字的大小。 如果在小于等于运算符左边的数字小于或者等于右边的数字,它会返回 `true`。 如果在小于等于运算符左边的数字大于右边的数字,它会返回 `false`。 与相等运算符类似,小于或等于运算符会转换数据类型。
-**Examples**
+**例如**
```js
-4 <= 5 // true
-'7' <= 7 // true
-5 <= 5 // true
-3 <= 2 // false
-'8' <= 4 // false
+4 <= 5
+'7' <= 7
+5 <= 5
+3 <= 2
+'8' <= 4
```
+按顺序,这些表达式会返回 `true`、`true`、`true`、`false` 和 `false`。
+
# --instructions--
-Add the less than or equal to operator to the indicated lines so that the return statements make sense.
+添加小于等于运算符到指定行,使得函数的返回语句有意义。
# --hints--
-`testLessOrEqual(0)` should return "Smaller Than or Equal to 12"
+`testLessOrEqual(0)` 应该返回 `Smaller Than or Equal to 12`
```js
assert(testLessOrEqual(0) === 'Smaller Than or Equal to 12');
```
-`testLessOrEqual(11)` should return "Smaller Than or Equal to 12"
+`testLessOrEqual(11)` 应该返回 `Smaller Than or Equal to 12`
```js
assert(testLessOrEqual(11) === 'Smaller Than or Equal to 12');
```
-`testLessOrEqual(12)` should return "Smaller Than or Equal to 12"
+`testLessOrEqual(12)` 应该返回 `Smaller Than or Equal to 12`
```js
assert(testLessOrEqual(12) === 'Smaller Than or Equal to 12');
```
-`testLessOrEqual(23)` should return "Smaller Than or Equal to 24"
+`testLessOrEqual(23)` 应该返回 `Smaller Than or Equal to 24`
```js
assert(testLessOrEqual(23) === 'Smaller Than or Equal to 24');
```
-`testLessOrEqual(24)` should return "Smaller Than or Equal to 24"
+`testLessOrEqual(24)` 应该返回 `Smaller Than or Equal to 24`
```js
assert(testLessOrEqual(24) === 'Smaller Than or Equal to 24');
```
-`testLessOrEqual(25)` should return "More Than 24"
+`testLessOrEqual(25)` 应该返回 `More Than 24`
```js
assert(testLessOrEqual(25) === 'More Than 24');
```
-`testLessOrEqual(55)` should return "More Than 24"
+`testLessOrEqual(55)` 应该返回 `More Than 24`
```js
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);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator.md
index b8d73b9aa4..4caaf30c2c 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-equality-operator.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244d1
-title: Comparison with the Strict Equality Operator
+title: 严格相等运算符
challengeType: 1
videoUrl: 'https://scrimba.com/c/cy87atr'
forumTopicId: 16790
@@ -9,44 +9,46 @@ dashedName: comparison-with-the-strict-equality-operator
# --description--
-Strict equality (`===`) is the counterpart to the equality operator (`==`). However, unlike the equality operator, which attempts to convert both values being compared to a common type, the strict equality operator does not perform a type conversion.
+严格相等运算符(`===`)是相对相等操作符(`==`)的另一种比较操作符。 与相等操作符转换数据两类型不同,严格相等运算符不会做类型转换。
-If the values being compared have different types, they are considered unequal, and the strict equality operator will return false.
+如果比较的值类型不同,那么在严格相等运算符比较下它们是不相等的,会返回 false 。
-**Examples**
+**示例**
```js
-3 === 3 // true
-3 === '3' // false
+3 === 3
+3 === '3'
```
-In the second example, `3` is a `Number` type and `'3'` is a `String` type.
+这些条件将分别返回 `true` and `false`。
+
+在第二个例子中,`3` 是一个 `Number` 类型,而 `'3'` 是一个 `String` 类型。
# --instructions--
-Use the strict equality operator in the `if` statement so the function will return "Equal" when `val` is strictly equal to `7`
+在 `if` 语句中,添加不相等运算符,这样函数在当 `val` 严格等于 `7` 的时候,会返回 `Equal`。
# --hints--
-`testStrict(10)` should return "Not Equal"
+`testStrict(10)` 应该返回字符串 `Not Equal`
```js
assert(testStrict(10) === 'Not Equal');
```
-`testStrict(7)` should return "Equal"
+`testStrict(7)` 应该返回字符串 `Equal`
```js
assert(testStrict(7) === 'Equal');
```
-`testStrict("7")` should return "Not Equal"
+`testStrict("7")` 应该返回字符串 `Not Equal`
```js
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);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator.md
index bf9c2a6c1a..6dd5f15f24 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244d8
-title: Comparisons with the Logical And Operator
+title: 逻辑与运算符
challengeType: 1
videoUrl: 'https://scrimba.com/c/cvbRVtr'
forumTopicId: 16799
@@ -9,9 +9,9 @@ dashedName: comparisons-with-the-logical-and-operator
# --description--
-Sometimes you will need to test more than one thing at a time. The logical and operator (`&&`) returns `true` if and only if the operands to the left and right of it are true.
+有时你需要在一次判断中做多个操作。 当且仅当运算符的左边和右边都是 true,逻辑与运算符(`&&`)才会返回`true`。
-The same effect could be achieved by nesting an if statement inside another if:
+同样的效果可以通过 if 语句的嵌套来实现:
```js
if (num > 5) {
@@ -22,7 +22,7 @@ if (num > 5) {
return "No";
```
-will only return "Yes" if `num` is greater than `5` and less than `10`. The same logic can be written as:
+只有当 `num` 的值大于 `5` 并且小于`10` 时才会返回 `Yes`。 相同的逻辑可被写为:
```js
if (num > 5 && num < 10) {
@@ -33,65 +33,65 @@ return "No";
# --instructions--
-Replace the two if statements with one statement, using the && operator, which will return `"Yes"` if `val` is less than or equal to `50` and greater than or equal to `25`. Otherwise, will return `"No"`.
+请使用 `&&` 运算符把两个 if 语句合并为一个 if 语句,如果 `val` 小于或等于`50` 并且大于或等于 `25` 时,返回 `Yes`。 否则,将返回`No`。
# --hints--
-You should use the `&&` operator once
+你应该使用 `&&` 运算符一次。
```js
assert(code.match(/&&/g).length === 1);
```
-You should only have one `if` statement
+你应该只有一个 `if` 表达式。
```js
assert(code.match(/if/g).length === 1);
```
-`testLogicalAnd(0)` should return "No"
+`testLogicalAnd(0)` 应该返回字符串 `No`
```js
assert(testLogicalAnd(0) === 'No');
```
-`testLogicalAnd(24)` should return "No"
+`testLogicalAnd(24)` 应该返回字符串 `No`
```js
assert(testLogicalAnd(24) === 'No');
```
-`testLogicalAnd(25)` should return "Yes"
+`testLogicalAnd(25)` 应该返回字符串 `Yes`
```js
assert(testLogicalAnd(25) === 'Yes');
```
-`testLogicalAnd(30)` should return "Yes"
+`testLogicalAnd(30)` 应该返回字符串 `Yes`
```js
assert(testLogicalAnd(30) === 'Yes');
```
-`testLogicalAnd(50)` should return "Yes"
+`testLogicalAnd(50)` 应该返回字符串 `Yes`
```js
assert(testLogicalAnd(50) === 'Yes');
```
-`testLogicalAnd(51)` should return "No"
+`testLogicalAnd(51)` 应该返回字符串 `No`
```js
assert(testLogicalAnd(51) === 'No');
```
-`testLogicalAnd(75)` should return "No"
+`testLogicalAnd(75)` 应该返回字符串 `No`
```js
assert(testLogicalAnd(75) === 'No');
```
-`testLogicalAnd(80)` should return "No"
+`testLogicalAnd(80)` 应该返回字符串 `No`
```js
assert(testLogicalAnd(80) === 'No');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-or-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-or-operator.md
index cd5d09d36f..75679a108a 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-or-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-or-operator.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244d9
-title: Comparisons with the Logical Or Operator
+title: 逻辑或运算符
challengeType: 1
videoUrl: 'https://scrimba.com/c/cEPrGTN'
forumTopicId: 16800
@@ -9,11 +9,11 @@ dashedName: comparisons-with-the-logical-or-operator
# --description--
-The logical or operator (`||`) returns `true` if either of the operands is `true`. Otherwise, it returns `false`.
+只要逻辑或运算符(`||`)两边的任何一个运算的结果是 `true`,则返回 `true`。 否则,返回 `false`。
-The logical or operator is composed of two pipe symbols: (`||`). This can typically be found between your Backspace and Enter keys.
+逻辑或运算符由两个竖线(`||`)组成。 这个按键位于退格键和回车键之间。
-The pattern below should look familiar from prior waypoints:
+下面这样的语句你应该很熟悉:
```js
if (num > 10) {
@@ -25,7 +25,7 @@ if (num < 5) {
return "Yes";
```
-will return "Yes" only if `num` is between `5` and `10` (5 and 10 included). The same logic can be written as:
+只有当 `num` 大于等于 `5` 或小于等于 `10` 时,函数才返回 `Yes`。 相同的逻辑可以简写成:
```js
if (num > 10 || num < 5) {
@@ -36,65 +36,65 @@ return "Yes";
# --instructions--
-Combine the two `if` statements into one statement which returns `"Outside"` if `val` is not between `10` and `20`, inclusive. Otherwise, return `"Inside"`.
+请使用逻辑或运算符把两个 `if` 语句合并为一个语句,如果 `val` 不在 `10` 和 `20` 之间(包括 10 和 20),返回 `Outside`。 否则,返回 `Inside`。
# --hints--
-You should use the `||` operator once
+应该使用一次 `||` 操作符。
```js
assert(code.match(/\|\|/g).length === 1);
```
-You should only have one `if` statement
+应该只有一个 `if` 表达式。
```js
assert(code.match(/if/g).length === 1);
```
-`testLogicalOr(0)` should return "Outside"
+`testLogicalOr(0)` 应该返回字符串 `Outside`
```js
assert(testLogicalOr(0) === 'Outside');
```
-`testLogicalOr(9)` should return "Outside"
+`testLogicalOr(9)` 应该返回字符串 `Outside`
```js
assert(testLogicalOr(9) === 'Outside');
```
-`testLogicalOr(10)` should return "Inside"
+`testLogicalOr(10)` 应该返回字符串 `Inside`
```js
assert(testLogicalOr(10) === 'Inside');
```
-`testLogicalOr(15)` should return "Inside"
+`testLogicalOr(15)` 应该返回字符串 `Inside`
```js
assert(testLogicalOr(15) === 'Inside');
```
-`testLogicalOr(19)` should return "Inside"
+`testLogicalOr(19)` 应该返回字符串 `Inside`
```js
assert(testLogicalOr(19) === 'Inside');
```
-`testLogicalOr(20)` should return "Inside"
+`testLogicalOr(20)` 应该返回字符串 `Inside`
```js
assert(testLogicalOr(20) === 'Inside');
```
-`testLogicalOr(21)` should return "Outside"
+`testLogicalOr(21)` 应该返回字符串 `Outside`
```js
assert(testLogicalOr(21) === 'Outside');
```
-`testLogicalOr(25)` should return "Outside"
+`testLogicalOr(25)` 应该返回字符串 `Outside`
```js
assert(testLogicalOr(25) === 'Outside');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md
index 0a2ab04992..01e2a687b3 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/compound-assignment-with-augmented-addition.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244af
-title: Compound Assignment With Augmented Addition
+title: 复合赋值之 +=
challengeType: 1
videoUrl: 'https://scrimba.com/c/cDR6LCb'
forumTopicId: 16661
@@ -9,51 +9,53 @@ dashedName: compound-assignment-with-augmented-addition
# --description--
-In programming, it is common to use assignments to modify the contents of a variable. Remember that everything to the right of the equals sign is evaluated first, so we can say:
+在编程中,通常通过赋值来修改变量的内容。 记住,赋值时 JavaScript 会先计算等号右边的内容,所以我们可以写这样的语句:
`myVar = myVar + 5;`
-to add `5` to `myVar`. Since this is such a common pattern, there are operators which do both a mathematical operation and assignment in one step.
+给 `myVar` 加上 `5`。 以上是最常见的运算赋值语句,即先运算、再赋值。还有一类操作符是一步到位既做运算也赋值的。
-One such operator is the `+=` operator.
+其中一种就是 `+=` 运算符。
```js
var myVar = 1;
myVar += 5;
-console.log(myVar); // Returns 6
+console.log(myVar);
```
+字符串 `6` 将会出现在控制台中。
+
# --instructions--
-Convert the assignments for `a`, `b`, and `c` to use the `+=` operator.
+使用 `+=` 操作符对 `a`、`b` 和 `c` 实现同样的效果。
# --hints--
-`a` should equal `15`.
+`a` 应该等于 `15`。
```js
assert(a === 15);
```
-`b` should equal `26`.
+`b` 应该等于 `26`。
```js
assert(b === 26);
```
-`c` should equal `19`.
+`c` 应该等于 `19`。
```js
assert(c === 19);
```
-You should use the `+=` operator for each variable.
+应该对每个变量使用 `+=` 操作符。
```js
assert(code.match(/\+=/g).length === 3);
```
-You should not modify the code above the specified comment.
+不要修改注释上面的代码。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md
index ec94ec73ed..87f55cf977 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244b7
-title: Concatenating Strings with Plus Operator
+title: 用加号运算符连接字符串
challengeType: 1
videoUrl: 'https://scrimba.com/c/cNpM8AN'
forumTopicId: 16802
@@ -9,49 +9,48 @@ dashedName: concatenating-strings-with-plus-operator
# --description--
-In JavaScript, when the `+` operator is used with a `String` value, it is called the concatenation operator. You can build a new string out of other strings by concatenating them together.
+在 JavaScript 中,当 `+` 操作符被用于一个 `String` 类型的值的时候,它被称作拼接操作符。 你可以通过拼接其他字符串来创建一个新的字符串。
-**Example**
+**例如:**
```js
'My name is Alan,' + ' I concatenate.'
```
-**Note**
-Watch out for spaces. Concatenation does not add spaces between concatenated strings, so you'll need to add them yourself.
+**提示:**注意空格。 拼接操作不会在两个字符串之间添加空格。所以,如果想加上空格的话,你需要自己在字符串里面添加。
-Example:
+例如:
```js
var ourStr = "I come first. " + "I come second.";
-// ourStr is "I come first. I come second."
```
+字符串 `I come first. I come second.` 将显示在控制台中。
# --instructions--
-Build `myStr` from the strings `"This is the start. "` and `"This is the end."` using the `+` operator.
+使用 `+` 操作符连接字符串`This is the start.` 和 `This is the end.` 赋值给 `myStr` 。
# --hints--
-`myStr` should have a value of `This is the start. This is the end.`
+`myStr` 的值应该是 `This is the start. This is the end.`
```js
assert(myStr === 'This is the start. This is the end.');
```
-You should use the `+` operator to build `myStr`.
+应使用 `+` 操作符创建 `myStr`。
```js
assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));
```
-`myStr` should be created using the `var` keyword.
+应使用 `var` 关键字创建 `myStr`。
```js
assert(/var\s+myStr/.test(code));
```
-You should assign the result to the `myStr` variable.
+应把结果赋值给 `myStr` 变量。
```js
assert(/myStr\s*=/.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator.md
index e1bf723545..c963cb952a 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244b8
-title: Concatenating Strings with the Plus Equals Operator
+title: 用 += 运算符连接字符串
challengeType: 1
videoUrl: 'https://scrimba.com/c/cbQmmC4'
forumTopicId: 16803
@@ -9,32 +9,32 @@ dashedName: concatenating-strings-with-the-plus-equals-operator
# --description--
-We can also use the `+=` operator to concatenate a string onto the end of an existing string variable. This can be very helpful to break a long string over several lines.
+我们还可以使用 `+=` 运算符来拼接字符串到现有字符串变量的结尾。 对于那些被分割成几段的长的字符串来说,这一操作是非常有用的。
-**Note**
-Watch out for spaces. Concatenation does not add spaces between concatenated strings, so you'll need to add them yourself.
+**提示:**注意空格。 拼接操作不会在两个字符串之间添加空格,所以,如果想要加上空格的话,你需要自己在字符串里面添加。
-Example:
+例如:
```js
var ourStr = "I come first. ";
ourStr += "I come second.";
-// ourStr is now "I come first. I come second."
```
+`ourStr` 现在内容为字符串 `I come first. I come second.`
+
# --instructions--
-Build `myStr` over several lines by concatenating these two strings: `"This is the first sentence. "` and `"This is the second sentence."` using the `+=` operator. Use the `+=` operator similar to how it is shown in the editor. Start by assigning the first string to `myStr`, then add on the second string.
+使用 `+=` 操作符,多行合并字符串 `This is the first sentence.` 和 `This is the second sentence.` ,并赋值给 `myStr` 。 像编辑器里显示的那样使用 `+=` 操作符。 先把第一个字符串赋值给 `myStr`,然后拼接第二个字符串。
# --hints--
-`myStr` should have a value of `This is the first sentence. This is the second sentence.`
+`myStr` 的值应该是 `This is the first sentence. This is the second sentence.`
```js
assert(myStr === 'This is the first sentence. This is the second sentence.');
```
-You should use the `+=` operator to build `myStr`.
+应该使用 `+=` 操作符创建 `myStr` 变量。
```js
assert(code.match(/myStr\s*\+=\s*(["']).*\1/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/constructing-strings-with-variables.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/constructing-strings-with-variables.md
index 183aa48865..9c637cd5f3 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/constructing-strings-with-variables.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/constructing-strings-with-variables.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244b9
-title: Constructing Strings with Variables
+title: 用变量构造字符串
challengeType: 1
videoUrl: 'https://scrimba.com/c/cqk8rf4'
forumTopicId: 16805
@@ -9,29 +9,30 @@ dashedName: constructing-strings-with-variables
# --description--
-Sometimes you will need to build a string, [Mad Libs](https://en.wikipedia.org/wiki/Mad_Libs) style. By using the concatenation operator (`+`), you can insert one or more variables into a string you're building.
+有时候你需要创建一个类似 [Mad Libs](https://en.wikipedia.org/wiki/Mad_Libs)(填词游戏)风格的字符串。 通过使用连接运算符(`+`),你可以插入一个或多个变量来组成一个字符串。
-Example:
+例如:
```js
var ourName = "freeCodeCamp";
var ourStr = "Hello, our name is " + ourName + ", how are you?";
-// ourStr is now "Hello, our name is freeCodeCamp, how are you?"
```
+`ourStr` 值为 `Hello, our name is freeCodeCamp, how are you?`
+
# --instructions--
-Set `myName` to a string equal to your name and build `myStr` with `myName` between the strings `"My name is "` and `" and I am well!"`
+把你的名字赋值给变量 `myName`,然后把变量 `myName` 插入到字符串 `My name is` 和 `and I am well!` 之间,并把连接后的结果赋值给变量 `myStr`。
# --hints--
-`myName` should be set to a string at least 3 characters long.
+`myName` 应该是一个至少有 3 个字符的字符串。
```js
assert(typeof myName !== 'undefined' && myName.length > 2);
```
-You should use two `+` operators to build `myStr` with `myName` inside it.
+使用两个 `+` 操作符创建包含 `myName` 的 `myStr` 变量。
```js
assert(code.match(/["']\s*\+\s*myName\s*\+\s*["']/g).length > 0);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop.md
index 9edc5f1cb9..75e208e5b2 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop.md
@@ -1,6 +1,6 @@
---
id: 56105e7b514f539506016a5e
-title: Count Backwards With a For Loop
+title: 使用 For 循环反向遍历数组
challengeType: 1
videoUrl: 'https://scrimba.com/c/c2R6BHa'
forumTopicId: 16808
@@ -9,11 +9,11 @@ dashedName: count-backwards-with-a-for-loop
# --description--
-A for loop can also count backwards, so long as we can define the right conditions.
+只要我们定义好合适的条件,for 循环也可以反向遍历。
-In order to decrement by two each iteration, we'll need to change our `initialization`, `condition`, and `final-expression`.
+为了让每次递减 2,我们需要改变 initialization、condition 和 final-expression。
-We'll start at `i = 10` and loop while `i > 0`. We'll decrement `i` by 2 each loop with `i -= 2`.
+设置 `i = 10`,并且当 `i > 0` 的时候才继续循环。 我们使用 `i -= 2` 来让 `i` 每次循环递减 2。
```js
var ourArray = [];
@@ -22,27 +22,27 @@ for (var i = 10; i > 0; i -= 2) {
}
```
-`ourArray` will now contain `[10,8,6,4,2]`. Let's change our `initialization` and `final-expression` so we can count backward by twos by odd numbers.
+循环结束后,`ourArray` 的值为 `[10,8,6,4,2]`。 让我们改变 initialization 和 final-expression,这样我们就可以按照奇数从后往前两两倒着数。
# --instructions--
-Push the odd numbers from 9 through 1 to `myArray` using a `for` loop.
+使用一个 `for`循环,把从 9 到 1 的奇数添加到 `myArray`。
# --hints--
-You should be using a `for` loop for this.
+应该使用 `for` 循环。
```js
assert(/for\s*\([^)]+?\)/.test(code));
```
-You should be using the array method `push`.
+应该使用数组方法 `push`。
```js
assert(code.match(/myArray.push/));
```
-`myArray` should equal `[9,7,5,3,1]`.
+`myArray` 应该等于 `[9,7,5,3,1]`。
```js
assert.deepEqual(myArray, [9, 7, 5, 3, 1]);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/counting-cards.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/counting-cards.md
index 4d98fdecfb..8de2525b01 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/counting-cards.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/counting-cards.md
@@ -1,6 +1,6 @@
---
id: 565bbe00e9cc8ac0725390f4
-title: Counting Cards
+title: 21 点游戏
challengeType: 1
videoUrl: 'https://scrimba.com/c/c6KE7ty'
forumTopicId: 16809
@@ -9,25 +9,25 @@ dashedName: counting-cards
# --description--
-In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called [Card Counting](https://en.wikipedia.org/wiki/Card_counting).
+在赌场 21 点游戏中,玩家可以通过计算牌桌上已经发放的卡牌的高低值来让自己在游戏中保持优势。 这就叫 [21 点算法](https://en.wikipedia.org/wiki/Card_counting)。
-Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.
+牌桌上的大值的卡牌更多,对玩家有利。 根据下面的表格,每张卡牌都被分配了一个值。 如果卡牌的值大于 0,那么玩家应该追加赌注。 如果卡牌的值为 0 或负数,玩家应该追加少许赌注甚至不追加赌注。
-
/g));
```
-Your code should keep the double quotes around the entire string.
+你应该在整个字符串外围保留双引号。
```js
assert(code.match(/".*?<\/p>";/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing.md
index d86487c484..dcc3414cb3 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing.md
@@ -1,6 +1,6 @@
---
id: 587d7b86367417b2b2512b3b
-title: Catch Off By One Errors When Using Indexing
+title: 捕获使用索引的时候出现的错误
challengeType: 1
forumTopicId: 301189
dashedName: catch-off-by-one-errors-when-using-indexing
@@ -8,52 +8,51 @@ dashedName: catch-off-by-one-errors-when-using-indexing
# --description--
-Off by one errors (sometimes called OBOE) crop up when you're trying to target a specific index of a string or array (to slice or access a segment), or when looping over the indices of them. JavaScript indexing starts at zero, not one, which means the last index is always one less than the length of the item. If you try to access an index equal to the length, the program may throw an "index out of range" reference error or print `undefined`.
+当试图访问字符串或数组的特定索引(分割或访问一个片段)或循环索引时,有时会出现 Off by one errors 错误(有时称为 OBOE)。 JavaScript 索引从 0 开始,而不是 1,这意味着最后一个索引总会比字符串或数组的长度少 1。 如果尝试访问等于长度的索引,程序可能会抛出“索引超出范围”引用错误或打印出 `undefined`。
-When you use string or array methods that take index ranges as arguments, it helps to read the documentation and understand if they are inclusive (the item at the given index is part of what's returned) or not. Here are some examples of off by one errors:
+当使用将索引范围作为参数的字符串或数组方法时,阅读相关的文档并了解参数中的索引的包含性(即是否考虑进返回值中)很重要。 以下是一些错误的示例:
```js
let alphabet = "abcdefghijklmnopqrstuvwxyz";
let len = alphabet.length;
for (let i = 0; i <= len; i++) {
- // loops one too many times at the end
console.log(alphabet[i]);
}
for (let j = 1; j < len; j++) {
- // loops one too few times and misses the first character at index 0
console.log(alphabet[j]);
}
for (let k = 0; k < len; k++) {
- // Goldilocks approves - this is just right
console.log(alphabet[k]);
}
```
+第一个例子多了一次循环,第二个例子少了一次循环(漏掉了索引 0 处的字符), 第三个例子是正确的。
+
# --instructions--
-Fix the two indexing errors in the following function so all the numbers 1 through 5 are printed to the console.
+修复以下函数中的两个索引错误,将 1 到 5 之间(包含 1 和 5)的所有数字打印到控制台。
# --hints--
-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);
```
-Your code should fix the initial condition of the loop so that the index starts at 0.
+应修复循环的初始条件,使循环从索引 0 开始。
```js
assert(!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*?;/g).length == 1);
```
-Your code should fix the terminal condition of the loop so that it stops at 1 before the length.
+应该修复循环的终止条件,使循环在索引为字符串长度减 1 的位置停止。
```js
assert(!code.match(/i\s*?<=\s*?len;/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes.md
index a55d812d8a..b0a27ebc3e 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-unclosed-parentheses-brackets-braces-and-quotes.md
@@ -1,6 +1,6 @@
---
id: 587d7b84367417b2b2512b36
-title: 'Catch Unclosed Parentheses, Brackets, Braces and Quotes'
+title: '捕获未闭合的括号、方括号、大括号和引号'
challengeType: 1
forumTopicId: 301190
dashedName: catch-unclosed-parentheses-brackets-braces-and-quotes
@@ -8,23 +8,23 @@ dashedName: catch-unclosed-parentheses-brackets-braces-and-quotes
# --description--
-Another syntax error to be aware of is that all opening parentheses, brackets, curly braces, and quotes have a closing pair. Forgetting a piece tends to happen when you're editing existing code and inserting items with one of the pair types. Also, take care when nesting code blocks into others, such as adding a callback function as an argument to a method.
+要注意的另一个语法错误是所有的小括号、方括号、花括号和引号都必须配对。 当你编辑代码并插入新代码其中带有括号时,很容易忘记括号闭合。 此外,在将代码块嵌套到其他代码块时要小心,例如将回调函数作为参数添加到方法中。
-One way to avoid this mistake is as soon as the opening character is typed, immediately include the closing match, then move the cursor back between them and continue coding. Fortunately, most modern code editors generate the second half of the pair automatically.
+避免这种错误的一种方法是,一次性输入完这些符号,然后将光标移回它们之间继续编写。 好在现在大部分编辑器都会帮你自动补全。
# --instructions--
-Fix the two pair errors in the code.
+修复代码中的两个符号配对错误。
# --hints--
-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));
```
-Your code should fix the missing piece of the `.reduce()` method. The console output should show that "Sum of array values is: 6".
+应该修复 `.reduce()` 方法缺少的部分。 控制台应该输出 `Sum of array values is: 6`。
```js
assert(arraySum === 6);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-use-of-assignment-operator-instead-of-equality-operator.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-use-of-assignment-operator-instead-of-equality-operator.md
index e164f37399..20382d231e 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-use-of-assignment-operator-instead-of-equality-operator.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/catch-use-of-assignment-operator-instead-of-equality-operator.md
@@ -1,6 +1,6 @@
---
id: 587d7b85367417b2b2512b38
-title: Catch Use of Assignment Operator Instead of Equality Operator
+title: 捕获使用赋值运算符而不是相等运算符
challengeType: 1
forumTopicId: 301191
dashedName: catch-use-of-assignment-operator-instead-of-equality-operator
@@ -8,37 +8,39 @@ dashedName: catch-use-of-assignment-operator-instead-of-equality-operator
# --description--
-Branching programs, i.e. ones that do different things if certain conditions are met, rely on `if`, `else if`, and `else` statements in JavaScript. The condition sometimes takes the form of testing whether a result is equal to a value.
+分支程序,即在满足某些条件时执行不同操作的程序,依赖于 JavaScript 中的`if`,`else if`、`else`语句。 条件有时采取测试一个结果是否等于一个值的形式。
-This logic is spoken (in English, at least) as "if x equals y, then ..." which can literally translate into code using the `=`, or assignment operator. This leads to unexpected control flow in your program.
+这种逻辑可以表述为“如果 x 等于 y ,则......”,听起来像是可以使用 `=`(即赋值运算符)。 然而,这会导致程序中流程出问题。
-As covered in previous challenges, the assignment operator (`=`) in JavaScript assigns a value to a variable name. And the `==` and `===` operators check for equality (the triple `===` tests for strict equality, meaning both value and type are the same).
+如前面的挑战所述,JavaScript 中的赋值运算符 (`=`) 是用来为变量名赋值的。 并且 `==` 和 `===` 运算符检查相等性(三等号 `===` 是用来测试是否严格相等的,严格相等的意思是值和类型都必须相同)。
-The code below assigns `x` to be 2, which evaluates as `true`. Almost every value on its own in JavaScript evaluates to `true`, except what are known as the "falsy" values: `false`, `0`, `""` (an empty string), `NaN`, `undefined`, and `null`.
+下面的代码将 `x` 赋值为 2,表达式会在执行后得到 `true`。 JavaScript 会把大部分的值都视为 `true`,除了所谓的 “falsy”值,即:`false`、`0`、`""`(空字符串)、`NaN`、`undefined` 和 `null`。
```js
let x = 1;
let y = 2;
if (x = y) {
- // this code block will run for any value of y (unless y were originally set as a falsy)
+
} else {
- // this code block is what should run (but won't) in this example
+
}
```
+在这个示例中,除非 `y` 值是假值,否则当 `y` 为任何值时,`if` 语句中的代码块都会运行。 我们期望运行的 `else` 代码块实际上将不会运行。
+
# --instructions--
-Fix the condition so the program runs the right branch, and the appropriate value is assigned to `result`.
+修复条件语句,以便程序运行正确的分支,并给 `result` 赋正确的值。
# --hints--
-Your code should fix the condition so it checks for equality, instead of using assignment.
+应该修复条件语句,使其判断是否相等,而不是赋值。
```js
assert(result == 'Not equal!');
```
-The condition should use either `==` or `===` to test for equality.
+条件语句可以使用 `==` 或 `===` 来测试是否相等。
```js
assert(code.match(/x\s*?===?\s*?y/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/prevent-infinite-loops-with-a-valid-terminal-condition.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/prevent-infinite-loops-with-a-valid-terminal-condition.md
index 9455e13645..442bbd6e39 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/prevent-infinite-loops-with-a-valid-terminal-condition.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/prevent-infinite-loops-with-a-valid-terminal-condition.md
@@ -1,6 +1,6 @@
---
id: 587d7b86367417b2b2512b3d
-title: Prevent Infinite Loops with a Valid Terminal Condition
+title: 使用有效的终止条件防止无限循环
challengeType: 1
forumTopicId: 301192
dashedName: prevent-infinite-loops-with-a-valid-terminal-condition
@@ -8,9 +8,9 @@ dashedName: prevent-infinite-loops-with-a-valid-terminal-condition
# --description--
-The final topic is the dreaded infinite loop. Loops are great tools when you need your program to run a code block a certain number of times or until a condition is met, but they need a terminal condition that ends the looping. Infinite loops are likely to freeze or crash the browser, and cause general program execution mayhem, which no one wants.
+最后一个话题是可怕的无限循环。 当需要程序运行代码块一定次数或满足条件时,循环是很好的工具,但是它们需要终止条件来结束循环。 无限循环可能会使浏览器冻结或崩溃,并导致程序执行混乱,没有人想要这样的结果。
-There was an example of an infinite loop in the introduction to this section - it had no terminal condition to break out of the `while` loop inside `loopy()`. Do NOT call this function!
+在本节的介绍中有一个无限循环的例子——它没有终止条件来摆脱`loopy()`内的`while`循环。 不要调用这个函数!
```js
function loopy() {
@@ -20,21 +20,21 @@ function loopy() {
}
```
-It's the programmer's job to ensure that the terminal condition, which tells the program when to break out of the loop code, is eventually reached. One error is incrementing or decrementing a counter variable in the wrong direction from the terminal condition. Another one is accidentally resetting a counter or index variable within the loop code, instead of incrementing or decrementing it.
+程序员的工作是确保最终达到终止条件,该条件告诉程序何时跳出循环。 有一种错误是从终端条件向错误方向递增或递减计数器变量。 另一种是在循环代码中意外重置计数器或索引变量,而不是递增或递减它。
# --instructions--
-The `myFunc()` function contains an infinite loop because the terminal condition `i != 4` will never evaluate to `false` (and break the looping) - `i` will increment by 2 each pass, and jump right over 4 since `i` is odd to start. Fix the comparison operator in the terminal condition so the loop only runs for `i` less than or equal to 4.
+`myFunc()`函数包含一个无限循环,因为终止条件`i != 4`永远不会为`false`(并中断循环) -`i`将每次递增 2,然后跳过 4,因为`i`是从奇数开始递增。 在终端条件中输入比较运算符,使循环仅在`i`小于或等于 4 的情况下运行。
# --hints--
-Your code should change the comparison operator in the terminal condition (the middle part) of the `for` loop.
+你应该在`for`循环的终止条件(中间部分)中更改比较运算符。
```js
assert(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));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md
index 10f47a1581..fb98d4921b 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md
@@ -1,6 +1,6 @@
---
id: 587d7b83367417b2b2512b37
-title: Understanding the Differences between the freeCodeCamp and Browser Console
+title: 了解 freeCodeCamp 和浏览器控制台之间的差异
challengeType: 1
forumTopicId: 301193
dashedName: understanding-the-differences-between-the-freecodecamp-and-browser-console
@@ -8,27 +8,27 @@ dashedName: understanding-the-differences-between-the-freecodecamp-and-browser-c
# --description--
-You may have noticed that some freeCodeCamp JavaScript challenges include their own console. This console behaves a little differently than the browser console you used in the last challenge.
+你可能已经注意到一些 freeCodeCamp JavaScript 的挑战有自己的控制台。 这些控制台的行为与上一次挑战中使用的浏览器控制台略有不同。
-The following challenge is meant to highlight the main difference between the freeCodeCamp console and your browser console.
+以下挑战旨在强调 freeCodeCamp 控制台与浏览器控制台之间的一些差异。
-When you run ordinary JavaScript, the browser's console will display your `console.log()` statements the exact number of times it is called.
+当在浏览器中加载并运行 JavaScript 文件时,`console.log()` 语句会在控制台中按照调用的次数准确地打印出要求的内容。
-The freeCodeCamp console will print your `console.log()` statements a short time after the editor detects a change in the script, as well as during testing.
+在编辑器检测到脚本中的更改之后,以及测试期间,freeCodeCamp 控制台将打印 `console.log()` 语句。
-The freeCodeCamp console is cleared before the tests are run and, to avoid spam, only prints the logs during the first test (see the note below for exceptions).
+在运行测试之前,将清除 freeCodeCamp 控制台,为避免破坏,仅在第一次测试期间打印日志(请参见下面的注释)。
-If you would like to see every log for every test, run the tests, and open the browser console. If you prefer to use the browser console, and want it to mimic the freeCodeCamp console, place `console.clear()` before any other `console` calls, to clear the browser console.
+如果你想看到每次测试的日志,运行测试,并打开浏览器控制台。 如果你喜欢使用浏览器控制台,想要它模仿 freeCodeCamp 控制台,请在其他 `console` 调用前加上 `console.clear()`,以清除浏览器控制台。
-**Note:** `console.log`s inside functions are printed to the freeCodeCamp console whenever those functions are called, this can help debugging functions that are called during testing.
+**注意:** 每次调用函数时,函数内的 `console.log` 都会被打印到 freeCodeCamp 控制台。 这样可以帮助在测试期间调试函数。
# --instructions--
-First, use `console.log` to log the `output` variable. Then, use `console.clear` to clear the browser console.
+首先,使用 `console.log` 打印 `output` 变量。 然后使用 `console.clear` 清除浏览器控制台。
# --hints--
-You should use `console.clear()` to clear the browser console.
+应该使用 `console.clear()` 清除浏览器控制台。
```js
assert(
@@ -38,7 +38,7 @@ assert(
);
```
-You should use `console.log()` to print the `output` variable.
+应该使用 `console.log()` 打印 `output` 变量。
```js
assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-caution-when-reinitializing-variables-inside-a-loop.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-caution-when-reinitializing-variables-inside-a-loop.md
index 19dd59b605..e13e375c3c 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-caution-when-reinitializing-variables-inside-a-loop.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-caution-when-reinitializing-variables-inside-a-loop.md
@@ -1,6 +1,6 @@
---
id: 587d7b86367417b2b2512b3c
-title: Use Caution When Reinitializing Variables Inside a Loop
+title: 重新初始化循环中的变量时要小心
challengeType: 1
forumTopicId: 301194
dashedName: use-caution-when-reinitializing-variables-inside-a-loop
@@ -8,29 +8,29 @@ dashedName: use-caution-when-reinitializing-variables-inside-a-loop
# --description--
-Sometimes it's necessary to save information, increment counters, or re-set variables within a loop. A potential issue is when variables either should be reinitialized, and aren't, or vice versa. This is particularly dangerous if you accidentally reset the variable being used for the terminal condition, causing an infinite loop.
+有时需要在循环中保存信息以增加计数器或重置变量。 一个潜在的问题是变量什么时候该重新初始化,什么时候不该重新初始化,反之亦然。 如果你不小心重置了用于终止条件的变量,导致无限循环,这将特别危险。
-Printing variable values with each cycle of your loop by using `console.log()` can uncover buggy behavior related to resetting, or failing to reset a variable.
+使用`console.log()`在每个循环中打印变量值可以发现与重置相关的错误或者重置变量失败。
# --instructions--
-The following function is supposed to create a two-dimensional array with `m` rows and `n` columns of zeroes. Unfortunately, it's not producing the expected output because the `row` variable isn't being reinitialized (set back to an empty array) in the outer loop. Fix the code so it returns a correct 3x2 array of zeroes, which looks like `[[0, 0], [0, 0], [0, 0]]`.
+以下函数应该创建一个具有`m`行和`n`列“零”的二维数组。 不幸的是,它没有产生预期的输出,因为`row`变量没有在外部循环中重新初始化(设置回空数组)。 修改代码,使其正确地返回包含 3 行 2 列“零”的二维数组,即`[[0, 0], [0, 0], [0, 0]]`。
# --hints--
-Your code should set the `matrix` variable to an array holding 3 rows of 2 columns of zeroes each.
+应将变量 `matrix` 设置为 3 行 2 列“零”的二维数组。
```js
assert(JSON.stringify(matrix) == '[[0,0],[0,0],[0,0]]');
```
-The `matrix` variable should have 3 rows.
+变量 `matrix` 应有 3 行。
```js
assert(matrix.length == 3);
```
-The `matrix` variable should have 2 columns in each row.
+变量 `matrix` 每行应有 2 列。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md
index eba2284614..d812da7f19 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-the-javascript-console-to-check-the-value-of-a-variable.md
@@ -1,6 +1,6 @@
---
id: 587d7b83367417b2b2512b33
-title: Use the JavaScript Console to Check the Value of a Variable
+title: 使用控制台检查变量值
challengeType: 1
forumTopicId: 18372
dashedName: use-the-javascript-console-to-check-the-value-of-a-variable
@@ -8,23 +8,23 @@ dashedName: use-the-javascript-console-to-check-the-value-of-a-variable
# --description--
-Both Chrome and Firefox have excellent JavaScript consoles, also known as DevTools, for debugging your JavaScript.
+Chrome 和 Firefox 都有出色的 JavaScript 控制台(也称为 DevTools),可以用来调试 JavaScript 代码
-You can find Developer tools in your Chrome's menu or Web Console in Firefox's menu. If you're using a different browser, or a mobile phone, we strongly recommend switching to desktop Firefox or Chrome.
+可以在 Chrome 的菜单中找到“开发者工具”或 FireFox 的菜单中的 “Web 控制台”。 如果你使用其他浏览器或手机,我们强烈建议你切换到桌面版 Firefox 或 Chrome。
-The `console.log()` method, which "prints" the output of what's within its parentheses to the console, will likely be the most helpful debugging tool. Placing it at strategic points in your code can show you the intermediate values of variables. It's good practice to have an idea of what the output should be before looking at what it is. Having check points to see the status of your calculations throughout your code will help narrow down where the problem is.
+`console.log()` 方法可能是最有用的调试工具,它可以将括号中的内容输出到控制台。 将它放在代码中的关键点可以显示变量在当时的值。 在查看输出之前,最好先想清楚输出应该是什么。 在整个代码中使用检查点来查看计算状态将有助于缩小问题的范围。
-Here's an example to print 'Hello world!' to the console:
+下面是输出 `Hello world!` 字符串到控制台的示例:
`console.log('Hello world!');`
# --instructions--
-Use the `console.log()` method to print the value of the variable `a` where noted in the code.
+请使用 `console.log()` 方法在代码中注明的地方输出变量 `a` 的值。
# --hints--
-Your code should use `console.log()` to check the value of the variable `a`.
+应使用 `console.log()` 来检查变量 `a` 的值。
```js
assert(code.match(/console\.log\(a\)/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-typeof-to-check-the-type-of-a-variable.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-typeof-to-check-the-type-of-a-variable.md
index e9d54bfb66..78dbbc97ca 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-typeof-to-check-the-type-of-a-variable.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/debugging/use-typeof-to-check-the-type-of-a-variable.md
@@ -1,6 +1,6 @@
---
id: 587d7b84367417b2b2512b34
-title: Use typeof to Check the Type of a Variable
+title: 使用 type of 检查变量的类型
challengeType: 1
forumTopicId: 18374
dashedName: use-typeof-to-check-the-type-of-a-variable
@@ -8,38 +8,40 @@ dashedName: use-typeof-to-check-the-type-of-a-variable
# --description--
-You can use `typeof` to check the data structure, or type, of a variable. This is useful in debugging when working with multiple data types. If you think you're adding two numbers, but one is actually a string, the results can be unexpected. Type errors can lurk in calculations or function calls. Be careful especially when you're accessing and working with external data in the form of a JavaScript Object Notation (JSON) object.
+可以使用 `typeof` 检查变量的数据结构或类型。 在处理多种数据类型时,这会对调试很有帮助。 如果想计算两数之和,但实际传入了一个字符串参数,则结果可能是错误的。 类型错误可能隐藏在计算或函数调用中。 当你以 JavaScript 对象(JSON)的形式访问和使用外部数据时尤其要小心。
-Here are some examples using `typeof`:
+下面是使用 `typeof` 的一些示例:
```js
-console.log(typeof ""); // outputs "string"
-console.log(typeof 0); // outputs "number"
-console.log(typeof []); // outputs "object"
-console.log(typeof {}); // outputs "object"
+console.log(typeof "");
+console.log(typeof 0);
+console.log(typeof []);
+console.log(typeof {});
```
-JavaScript recognizes six primitive (immutable) data types: `Boolean`, `Null`, `Undefined`, `Number`, `String`, and `Symbol` (new with ES6) and one type for mutable items: `Object`. Note that in JavaScript, arrays are technically a type of object.
+控制台将按顺序显示字符串 `string`、`number`、`object` 和 `object`。
+
+JavaScript 有六种原始(不可变)数据类型:`Boolean`、`Null`、`Undefined`、`Number`、`String` 和 `Symbol`(ES6 中新增的),和一种可变的数据类型:`Object`。 注意:在 JavaScript 中,数组在本质上是一种对象。
# --instructions--
-Add two `console.log()` statements to check the `typeof` each of the two variables `seven` and `three` in the code.
+添加两个 `console.log()` 语句来检查代码中的两个变量 `seven` 和 `three` 的 `typeof` 值。
# --hints--
-Your code should use `typeof` in two `console.log()` statements to check the type of the variables.
+应在两个 `console.log()` 语句中使用 `typeof` 来检查变量的类型。
```js
assert(code.match(/console\.log\(typeof[\( ].*\)?\)/g).length == 2);
```
-Your code should use `typeof` to check the type of the variable `seven`.
+应使用 `typeof` 来检查变量 `seven` 的类型。
```js
assert(code.match(/typeof[\( ]seven\)?/g));
```
-Your code should use `typeof` to check the type of the variable `three`.
+应使用 `typeof` 来检查变量 `three` 的类型。
```js
assert(code.match(/typeof[\( ]three\)?/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords.md
index ba319ea8bc..da1c1281d9 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords.md
@@ -1,6 +1,6 @@
---
id: 587d7b87367417b2b2512b40
-title: Compare Scopes of the var and let Keywords
+title: 比较 var 和 let 关键字的作用域
challengeType: 1
forumTopicId: 301195
dashedName: compare-scopes-of-the-var-and-let-keywords
@@ -8,11 +8,11 @@ dashedName: compare-scopes-of-the-var-and-let-keywords
# --description--
-When you declare a variable with the `var` keyword, it is declared globally, or locally if declared inside a function.
+使用 `var` 关键字来声明一个变量的时候,这个变量会被声明成全局变量,或是函数内的局部变量。
-The `let` keyword behaves similarly, but with some extra features. When you declare a variable with the `let` keyword inside a block, statement, or expression, its scope is limited to that block, statement, or expression.
+`let` 关键字的作用与此类似,但会有一些额外的特性。 如果在代码块、语句或表达式中使用关键字 `let` 声明变量,这个变量的作用域就被限制在当前的代码块、语句或表达式之中。
-For example:
+举个例子:
```js
var numArray = [];
@@ -20,12 +20,12 @@ for (var i = 0; i < 3; i++) {
numArray.push(i);
}
console.log(numArray);
-// returns [0, 1, 2]
console.log(i);
-// returns 3
```
-With the `var` keyword, `i` is declared globally. So when `i++` is executed, it updates the global variable. This code is similar to the following:
+这里控制台将显示值 `[0, 1, 2]` 和 `3`。
+
+因为使用了 `var` 关键字,`i` 被声明为全局变量。 所以当 `i++` 执行时,它会更新全局变量。 这个代码和下方的代码类似:
```js
var numArray = [];
@@ -34,12 +34,12 @@ for (i = 0; i < 3; i++) {
numArray.push(i);
}
console.log(numArray);
-// returns [0, 1, 2]
console.log(i);
-// returns 3
```
-This behavior will cause problems if you were to create a function and store it for later use inside a for loop that uses the `i` variable. This is because the stored function will always refer to the value of the updated global `i` variable.
+这里控制台将显示值 `[0, 1, 2]` 和 `3`。
+
+如果你创建一个函数,将它存储起来,稍后在使用 `i` 变量的 `for` 循环中使用。这么做可能会出现问题。 这是因为存储的函数会总是指向更新后的全局 `i` 变量的值。
```js
var printNumTwo;
@@ -51,10 +51,11 @@ for (var i = 0; i < 3; i++) {
}
}
console.log(printNumTwo());
-// returns 3
```
-As you can see, `printNumTwo()` prints 3 and not 2. This is because the value assigned to `i` was updated and the `printNumTwo()` returns the global `i` and not the value `i` had when the function was created in the for loop. The `let` keyword does not follow this behavior:
+这里控制台将显示值 `3`。
+
+可以看到,`printNumTwo()` 打印了 3,而不是 2。 这是因为赋值给 `i` 的值已经更新,`printNumTwo()` 返回全局的 `i`,而不是在 for 循环中创建函数时 `i` 的值。 `let` 关键字就不会出现这种现象:
```js
let printNumTwo;
@@ -66,28 +67,28 @@ for (let i = 0; i < 3; i++) {
}
}
console.log(printNumTwo());
-// returns 2
console.log(i);
-// returns "i is not defined"
```
-`i` is not defined because it was not declared in the global scope. It is only declared within the for loop statement. `printNumTwo()` returned the correct value because three different `i` variables with unique values (0, 1, and 2) were created by the `let` keyword within the loop statement.
+在这里控制台将显示值 `2` 和一个错误提示 `i is not defined`。
+
+`i` 未定义,因为它没有在全局范围内声明。 它只在 `for` 循环语句中被声明。 `printNumTwo()` 返回了正确的值,因为 `let` 关键字在循环语句中使 `i` 变量产生了三个不同的值(分别为 0、1、2)。
# --instructions--
-Fix the code so that `i` declared in the if statement is a separate variable than `i` declared in the first line of the function. Be certain not to use the `var` keyword anywhere in your code.
+修改这段代码,使 `if` 语句中声明的 `i` 变量与在函数的第一行声明的 `i` 变量是彼此独立的。 请注意不要在你的代码的任何地方使用 `var` 关键字。
-This exercise is designed to illustrate the difference between how `var` and `let` keywords assign scope to the declared variable. When programming a function similar to the one used in this exercise, it is often better to use different variable names to avoid confusion.
+这个练习旨在表明使用 `var` 与 `let` 关键字声明变量时作用域之间的区别。 当编写类似这个练习中的函数的时候,通常来说最好使用不同的变量名,以避免混淆。
# --hints--
-`var` should not exist in code.
+代码中不应该出现 `var`。
```js
(getUserInput) => assert(!getUserInput('index').match(/var/g));
```
-The variable `i` declared in the if statement should equal "block scope".
+`if` 语句中声明的变量 `i` 应该等于字符串 `block scope`。
```js
(getUserInput) =>
@@ -96,7 +97,7 @@ The variable `i` declared in the if statement should equal "block scope".
);
```
-`checkScope()` should return "function scope"
+`checkScope()` 应该返回字符串 `function scope`。
```js
assert(checkScope() === 'function scope');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/complete-a-promise-with-resolve-and-reject.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/complete-a-promise-with-resolve-and-reject.md
index 171b4f549c..e69a8e8618 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/complete-a-promise-with-resolve-and-reject.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/complete-a-promise-with-resolve-and-reject.md
@@ -1,6 +1,6 @@
---
id: 5cdafbc32913098997531680
-title: Complete a Promise with resolve and reject
+title: 通过 resolve 和 reject 完成 Promise
challengeType: 1
forumTopicId: 301196
dashedName: complete-a-promise-with-resolve-and-reject
@@ -8,7 +8,7 @@ dashedName: complete-a-promise-with-resolve-and-reject
# --description--
-A promise has three states: `pending`, `fulfilled`, and `rejected`. The promise you created in the last challenge is forever stuck in the `pending` state because you did not add a way to complete the promise. The `resolve` and `reject` parameters given to the promise argument are used to do this. `resolve` is used when you want your promise to succeed, and `reject` is used when you want it to fail. These are methods that take an argument, as seen below.
+Promise 有三个状态:`pending`、`fulfilled` 和 `rejected`。 上一个挑战里创建的 promise 一直阻塞在 `pending` 状态里,因为没有调用 promise 的完成方法。 Promise 提供的 `resolve` 和 `reject` 参数就是用来结束 promise 的。 Promise 成功时调用 `resolve`,promise 执行失败时调用 `reject`, 如下文所述,这些方法需要有一个参数。
```js
const myPromise = new Promise((resolve, reject) => {
@@ -20,15 +20,15 @@ const myPromise = new Promise((resolve, reject) => {
});
```
-The example above uses strings for the argument of these functions, but it can really be anything. Often, it might be an object, that you would use data from, to put on your website or elsewhere.
+上面的示例使用字符串作为这些函数的参数,但参数实际上可以是任何格式。 通常,它可能是一个包含数据的对象,你可以将它放在网站或其他地方。
# --instructions--
-Make the promise handle success and failure. If `responseFromServer` is `true`, call the `resolve` method to successfully complete the promise. Pass `resolve` a string with the value `We got the data`. If `responseFromServer` is `false`, use the `reject` method instead and pass it the string: `Data not received`.
+使 promise 可以处理成功和失败情况。 如果 `responseFromServer` 是 `true`,调用 `resolve` 方法使 promise 成功。 给 `resolve` 传递值为 `We got the data` 的字符串。 如果 `responseFromServer` 是 `false`, 使用 `reject` 方法并传入值为 `Data not received` 的字符串。
# --hints--
-`resolve` should be called with the expected string when the `if` condition is `true`.
+当 `if` 条件是 `true` 时应该执行 `resolve`。
```js
assert(
@@ -40,7 +40,7 @@ assert(
);
```
-`reject` should be called with the expected string when the `if` condition is `false`.
+当 `if` 条件是 `false` 时应该执行 `reject`。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.md
index 5dbc786915..c952955348 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-a-javascript-promise.md
@@ -1,6 +1,6 @@
---
id: 5cdafbb0291309899753167f
-title: Create a JavaScript Promise
+title: 创建一个 JavaScript Promise
challengeType: 1
forumTopicId: 301197
dashedName: create-a-javascript-promise
@@ -8,7 +8,7 @@ dashedName: create-a-javascript-promise
# --description--
-A promise in JavaScript is exactly what it sounds like - you use it to make a promise to do something, usually asynchronously. When the task completes, you either fulfill your promise or fail to do so. `Promise` is a constructor function, so you need to use the `new` keyword to create one. It takes a function, as its argument, with two parameters - `resolve` and `reject`. These are methods used to determine the outcome of the promise. The syntax looks like this:
+Promise 是异步编程的一种解决方案 - 它在未来的某时会生成一个值。 任务完成,分执行成功和执行失败两种情况。 `Promise` 是构造器函数,需要通过 `new` 关键字来创建。 构造器参数是一个函数,该函数有两个参数 - `resolve` 和 `reject`。 通过它们来判断 promise 的执行结果。 用法如下:
```js
const myPromise = new Promise((resolve, reject) => {
@@ -18,17 +18,17 @@ const myPromise = new Promise((resolve, reject) => {
# --instructions--
-Create a new promise called `makeServerRequest`. Pass in a function with `resolve` and `reject` parameters to the constructor.
+创建一个名为 `makeServerRequest` 的 promise。 给构造器函数传入 `resolve` 和 `reject` 两个参数。
# --hints--
-You should assign a promise to a declared variable named `makeServerRequest`.
+应该给名为 `makeServerRequest` 的变量指定一个 promise。
```js
assert(makeServerRequest instanceof Promise);
```
-Your promise should receive a function with `resolve` and `reject` as parameters.
+promise 应该接收一个函数做为参数,该函数应该包含 `resolve` 和 `reject` 两个参数。
```js
assert(
@@ -41,7 +41,9 @@ assert(
# --seed--
## --seed-contents--
+
```js
+
```
# --solutions--
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.md
index 507602f57d..65a908d7b8 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-a-module-script.md
@@ -1,6 +1,6 @@
---
id: 5cddbfd622f1a59093ec611d
-title: Create a Module Script
+title: 创建一个模块脚本
challengeType: 6
forumTopicId: 301198
dashedName: create-a-module-script
@@ -8,27 +8,27 @@ dashedName: create-a-module-script
# --description--
-JavaScript started with a small role to play on an otherwise mostly HTML web. Today, it’s huge, and some websites are built almost entirely with JavaScript. In order to make JavaScript more modular, clean, and maintainable; ES6 introduced a way to easily share code among JavaScript files. This involves exporting parts of a file for use in one or more other files, and importing the parts you need, where you need them. In order to take advantage of this functionality, you need to create a script in your HTML document with a type of `module`. Here’s an example:
+起初,JavaScript 几乎只在 HTML web 扮演一个很小的角色。 今天,一切不同了,很多网站几乎全是用 JavaScript 所写。 为了让 JavaScript 更模块化、更整洁以及更易于维护,ES6 引入了在多个 JavaScript 文件之间共享代码的机制。 它可以导出文件的一部分供其它文件使用,然后在需要它的地方按需导入。 为了使用这一功能, 需要在 HTML 文档里创建一个 `type` 为 `module` 的脚本。 例子如下:
```html
```
-A script that uses this `module` type can now use the `import` and `export` features you will learn about in the upcoming challenges.
+使用了 `module` 类型的脚本可以使用 `import` 和 `export` 特性(接下来的挑战会介绍)。
# --instructions--
-Add a script to the HTML document of type `module` and give it the source file of `index.js`
+给 HTML 文档添加 `module` 类型的脚本,指定源文件为 `index.js`。
# --hints--
-You should create a `script` tag.
+应该创建一个 `script` 标签。
```js
assert(code.match(/<\s*script[^>]*>\s*<\/\s*script\s*>/g));
```
-Your `script` tag should be of type `module`.
+`script` 标签应该有一个值为 `module` 的 `type` 属性。
```js
assert(
@@ -38,7 +38,7 @@ assert(
);
```
-Your `script` tag should have a `src` of `index.js`.
+`script` 标签的 `src` 属性应该为 `index.js`。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default.md
index ac32fc0848..23bcce9847 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-an-export-fallback-with-export-default.md
@@ -1,6 +1,6 @@
---
id: 587d7b8c367417b2b2512b58
-title: Create an Export Fallback with export default
+title: 用 export default 创建一个默认导出
challengeType: 1
forumTopicId: 301199
dashedName: create-an-export-fallback-with-export-default
@@ -8,33 +8,33 @@ dashedName: create-an-export-fallback-with-export-default
# --description--
-In the `export` lesson, you learned about the syntax referred to as a named export. This allowed you to make multiple functions and variables available for use in other files.
+在 `export` 的课程中,你学习了命名导出语法, 这可以在其他文件中引用一些函数或者变量。
-There is another `export` syntax you need to know, known as export default. Usually you will use this syntax if only one value is being exported from a file. It is also used to create a fallback value for a file or module.
+还需要了解另外一种被称为默认导出的 `export` 的语法。 在文件中只有一个值需要导出的时候,通常会使用这种语法。 它也常常用于给文件或者模块创建返回值。
-Below are examples using `export default`:
+下面是使用 `export default` 的例子:
```js
-// named function
export default function add(x, y) {
return x + y;
}
-// anonymous function
export default function(x, y) {
return x + y;
}
```
-Since `export default` is used to declare a fallback value for a module or file, you can only have one value be a default export in each module or file. Additionally, you cannot use `export default` with `var`, `let`, or `const`
+第一个是命名函数,第二个是匿名函数。
+
+`export default` 用于为模块或文件声明一个返回值,在每个文件或者模块中应当只默认导出一个值。 此外,你不能将 `export default` 与 `var`、`let` 或 `const` 同时使用。
# --instructions--
-The following function should be the fallback value for the module. Please add the necessary code to do so.
+下面的函数应该在这个模块中返回一个值。 请添加需要的代码。
# --hints--
-Your code should use `export` fallback.
+正确地使用 `export` 返回值。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md
index cd5c70bd6f..b89eccb84c 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/create-strings-using-template-literals.md
@@ -1,6 +1,6 @@
---
id: 587d7b8a367417b2b2512b4e
-title: Create Strings using Template Literals
+title: 使用模板字面量创建字符串
challengeType: 1
forumTopicId: 301200
dashedName: create-strings-using-template-literals
@@ -8,11 +8,11 @@ dashedName: create-strings-using-template-literals
# --description--
-A new feature of ES6 is the template literal. This is a special type of string that makes creating complex strings easier.
+模板字符串是 ES6 的另外一项新的功能。 这是一种可以轻松构建复杂字符串的方法。
-Template literals allow you to create multi-line strings and to use string interpolation features to create strings.
+模板字符串可以使用多行字符串和字符串插值功能。
-Consider the code below:
+请看以下代码:
```js
const person = {
@@ -20,23 +20,21 @@ const person = {
age: 56
};
-// Template literal with multi-line and string interpolation
const greeting = `Hello, my name is ${person.name}!
I am ${person.age} years old.`;
-console.log(greeting); // prints
-// Hello, my name is Zodiac Hasbro!
-// I am 56 years old.
-
+console.log(greeting);
```
-A lot of things happened there. Firstly, the example uses backticks (`` ` ``), not quotes (`'` or `"`), to wrap the string. Secondly, notice that the string is multi-line, both in the code and the output. This saves inserting `\n` within strings. The `${variable}` syntax used above is a placeholder. Basically, you won't have to use concatenation with the `+` operator anymore. To add variables to strings, you just drop the variable in a template string and wrap it with `${` and `}`. Similarly, you can include other expressions in your string literal, for example `${a + b}`. This new way of creating strings gives you more flexibility to create robust strings.
+控制台将显示字符串 `Hello, my name is Zodiac Hasbro!` 和 `I am 56 years old.`。
+
+这里发生了许多事情。 首先,这个例子使用反引号(`` ` ``),而不是引号(`'` 或者 `"`)将字符串括起来。 其次,注意代码和输出中的字符串都是多行的。 不需要在字符串中插入 `\n`。 上面使用的 `${variable}` 语法是一个占位符。 这样一来,你将不再需要使用 `+` 运算符来连接字符串。 当需要在字符串里增加变量的时候,你只需要在变量的外面括上 `${` 和 `}`,并将其放在模板字符串里就可以了。 同样,你可以在字符串中包含其他表达式,例如 `${a + b}`。 这个新的方式使你可以更灵活地创建复杂的字符串。
# --instructions--
-Use template literal syntax with backticks to create an array of list element (`li`) strings. Each list element's text should be one of the array elements from the `failure` property on the `result` object and have a `class` attribute with the value `text-warning`. The `makeList` function should return the array of list item strings.
+使用模板字符串的反引号的语法创建一个包含条目(`li`)字符串的数组。 每个条目应该是 `result` 对象 `failure` 属性的数组内的元素,并具有 `class` 属性,值为 `text-warning`。 `makeList` 函数应该返回列表项字符串的数组。
-Use an iterator method (any kind of loop) to get the desired output (shown below).
+使用遍历方法(可以是任意形式的循环)输出指定值(如下)。
```js
[
@@ -48,7 +46,7 @@ Use an iterator method (any kind of loop) to get the desired output (shown below
# --hints--
-`failuresList` should be an array containing `result failure` messages.
+`failuresList` 应该是一个包含了 `result failure` 信息的数组。
```js
assert(
@@ -56,7 +54,7 @@ assert(
);
```
-`failuresList` should be equal to the specified output.
+`failuresList` 应该输出指定的值。
```js
assert(
@@ -68,13 +66,13 @@ assert(
);
```
-Template strings and expression interpolation should be used.
+应使用模板字符串和表达式内插。
```js
(getUserInput) => assert(getUserInput('index').match(/(`.*\${.*}.*`)/));
```
-An iterator should be used.
+应该使用遍历。
```js
(getUserInput) =>
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword.md
index a869196788..332e86774e 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword.md
@@ -1,6 +1,6 @@
---
id: 587d7b87367417b2b2512b41
-title: Declare a Read-Only Variable with the const Keyword
+title: 用 const 关键字声明只读变量
challengeType: 1
forumTopicId: 301201
dashedName: declare-a-read-only-variable-with-the-const-keyword
@@ -8,44 +8,46 @@ dashedName: declare-a-read-only-variable-with-the-const-keyword
# --description--
-The keyword `let` is not the only new way to declare variables. In ES6, you can also declare variables using the `const` keyword.
+`let` 并不是唯一的新的声明变量的方式。 在 ES6 里面,你还可以使用 `const` 关键字来声明变量。
-`const` has all the awesome features that `let` has, with the added bonus that variables declared using `const` are read-only. They are a constant value, which means that once a variable is assigned with `const`, it cannot be reassigned.
+`const` 拥有 `let` 的所有优点,不同的是,通过 `const` 声明的变量是只读的。 这意味着通过 `const` 声明的变量只能被赋值一次,而不能被再次赋值。
```js
const FAV_PET = "Cats";
-FAV_PET = "Dogs"; // returns error
+FAV_PET = "Dogs";
```
-As you can see, trying to reassign a variable declared with `const` will throw an error. You should always name variables you don't want to reassign using the `const` keyword. This helps when you accidentally attempt to reassign a variable that is meant to stay constant. A common practice when naming constants is to use all uppercase letters, with words separated by an underscore.
+控制台将由于给 `FAV_PET` 重新赋值而显示错误。
-**Note:** It is common for developers to use uppercase variable identifiers for immutable values and lowercase or camelCase for mutable values (objects and arrays). In a later challenge you will see an example of a lowercase variable identifier being used for an array.
+可见,尝试给用 `const` 声明的变量重新赋值会报错。 你应该使用 `const` 关键字来声明所有不打算再次赋值的变量。 这有助于避免给一个常量进行额外的再次赋值。 一个最佳实践是对所有常量的命名采用全大写字母,并在单词之间使用下划线进行分隔。
+
+**注意:**通常,开发者会用大写字母作为常量标识符,用小写字母或者驼峰命名作为变量(对象或数组)标识符。 后面的挑战会涉及到在数组中使用小写变量标识符。
# --instructions--
-Change the code so that all variables are declared using `let` or `const`. Use `let` when you want the variable to change, and `const` when you want the variable to remain constant. Also, rename variables declared with `const` to conform to common practices, meaning constants should be in all caps.
+改变以下代码,使得所有的变量都使用 `let` 或 `const` 关键词来声明。 当变量将会改变的时候使用 `let` 关键字,当变量要保持常量的时候使用 `const` 关键字。 同时,对使用 `const` 声明的变量按照最佳实践重命名,变量名中的字母应该都是大写的。
# --hints--
-`var` should not exist in your code.
+代码中不应有 `var`。
```js
(getUserInput) => assert(!getUserInput('index').match(/var/g));
```
-`SENTENCE` should be a constant variable declared with `const`.
+`SENTENCE` 应该是使用 `const` 声明的常量。
```js
(getUserInput) => assert(getUserInput('index').match(/(const SENTENCE)/g));
```
-`i` should be declared with `let`.
+`i` 应该是使用 `let`声明的。
```js
(getUserInput) => assert(getUserInput('index').match(/(let i)/g));
```
-`console.log` should be changed to print the `SENTENCE` variable.
+`console.log` 应该修改为用于打印 `SENTENCE` 变量。
```js
(getUserInput) =>
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/explore-differences-between-the-var-and-let-keywords.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/explore-differences-between-the-var-and-let-keywords.md
index 7792ee384b..220c5a7c99 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/explore-differences-between-the-var-and-let-keywords.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/explore-differences-between-the-var-and-let-keywords.md
@@ -1,6 +1,6 @@
---
id: 587d7b87367417b2b2512b3f
-title: Explore Differences Between the var and let Keywords
+title: 探索 var 和 let 关键字之间的差异
challengeType: 1
forumTopicId: 301202
dashedName: explore-differences-between-the-var-and-let-keywords
@@ -8,49 +8,52 @@ dashedName: explore-differences-between-the-var-and-let-keywords
# --description--
-One of the biggest problems with declaring variables with the `var` keyword is that you can overwrite variable declarations without an error.
+使用 `var` 关键字来声明变量,会出现重复声明导致变量被覆盖却不会报错的问题。
```js
var camper = 'James';
var camper = 'David';
console.log(camper);
-// logs 'David'
```
-As you can see in the code above, the `camper` variable is originally declared as `James` and then overridden to be `David`. In a small application, you might not run into this type of problem, but when your code becomes larger, you might accidentally overwrite a variable that you did not intend to overwrite. Because this behavior does not throw an error, searching and fixing bugs becomes more difficult.
-A new keyword called `let` was introduced in ES6 to solve this potential issue with the `var` keyword. If you were to replace `var` with `let` in the variable declarations of the code above, the result would be an error.
+这里控制台将显示字符串 `David`。
+
+在上面的代码中,`camper` 变量的初始值为 `James`,然后又被覆盖成了 `David`。 在小型的应用中,你可能不会遇到这样的问题。但是当你的代码规模变得更加庞大的时候,就可能会在不经意间覆盖了之前定义的变量。 因为这样的情况不会报错,所以搜索和修复 bug 会变得非常困难。
+在 ES6 中引入了新的关键字 `let` 来解决 `var` 关键字带来的潜在问题。 如果你在上面的代码中使用 `let` 关键字来代替 `var` 关键字,结果会是一个报错。
```js
let camper = 'James';
-let camper = 'David'; // throws an error
+let camper = 'David';
```
-This error can be seen in the console of your browser. So unlike `var`, when using `let`, a variable with the same name can only be declared once. Note the `"use strict"`. This enables Strict Mode, which catches common coding mistakes and "unsafe" actions. For instance:
+你可以在浏览器的控制台里看见这个错误。 与 `var` 不同的是,当使用 `let` 的时候,同一名字的变量只能被声明一次。 请注意 `"use strict"`。 这代表着开启了严格模式,用于检测常见的代码错误以及“不安全”的行为, 例如:
```js
"use strict";
-x = 3.14; // throws an error because x is not declared
+x = 3.14;
```
+这将显示一个错误 `x is not defined`。
+
# --instructions--
-Update the code so it only uses the `let` keyword.
+请更新这段代码,只使用 `let` 关键字。
# --hints--
-`var` should not exist in the code.
+代码中不应有 `var`
```js
(getUserInput) => assert(!getUserInput('index').match(/var/g));
```
-`catName` should be `Oliver`.
+`catName` 变量的值应该为 `Oliver`
```js
assert(catName === 'Oliver');
```
-`quote` should be `"Oliver says Meow!"`
+`quote` 变量的值应该为 `Oliver says Meow!`
```js
assert(quote === 'Oliver says Meow!');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/handle-a-fulfilled-promise-with-then.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/handle-a-fulfilled-promise-with-then.md
index e39dd1da26..3609bbc3a4 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/handle-a-fulfilled-promise-with-then.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/handle-a-fulfilled-promise-with-then.md
@@ -1,6 +1,6 @@
---
id: 5cdafbd72913098997531681
-title: Handle a Fulfilled Promise with then
+title: 用 then 处理 Promise 完成的情况
challengeType: 1
forumTopicId: 301203
dashedName: handle-a-fulfilled-promise-with-then
@@ -8,23 +8,23 @@ dashedName: handle-a-fulfilled-promise-with-then
# --description--
-Promises are most useful when you have a process that takes an unknown amount of time in your code (i.e. something asynchronous), often a server request. When you make a server request it takes some amount of time, and after it completes you usually want to do something with the response from the server. This can be achieved by using the `then` method. The `then` method is executed immediately after your promise is fulfilled with `resolve`. Here’s an example:
+当程序需要花费未知的时间才能完成时(比如一些异步操作),一般是服务器请求,promise 很有用。 服务器请求会花费一些时间,当结束时,需要根据服务器的响应执行一些操作。 这可以用 `then` 方法来实现, 当 promise 完成 `resolve` 时会触发 `then` 方法。 例子如下:
```js
myPromise.then(result => {
- // do something with the result.
+
});
```
-`result` comes from the argument given to the `resolve` method.
+`result` 即传入 `resolve` 方法的参数。
# --instructions--
-Add the `then` method to your promise. Use `result` as the parameter of its callback function and log `result` to the console.
+给 promise 添加 `then` 方法。 用 `result` 做为回调函数的参数并将 `result` 打印在控制台。
# --hints--
-You should call the `then` method on the promise.
+应该给 promise 方法调用 `then` 方法。
```js
assert(
@@ -32,13 +32,13 @@ assert(
);
```
-Your `then` method should have a callback function with `result` as its parameter.
+`then` 方法应该有一个回调函数,回调函数参数为 `result`。
```js
assert(resultIsParameter);
```
-You should log `result` to the console.
+应该打印 `result` 到控制台。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/handle-a-rejected-promise-with-catch.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/handle-a-rejected-promise-with-catch.md
index 815c4b4786..78fc588df0 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/handle-a-rejected-promise-with-catch.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/handle-a-rejected-promise-with-catch.md
@@ -1,6 +1,6 @@
---
id: 5cdafbe72913098997531682
-title: Handle a Rejected Promise with catch
+title: 使用 catch 处理 Promise 失败的情况
challengeType: 1
forumTopicId: 301204
dashedName: handle-a-rejected-promise-with-catch
@@ -8,23 +8,23 @@ dashedName: handle-a-rejected-promise-with-catch
# --description--
-`catch` is the method used when your promise has been rejected. It is executed immediately after a promise's `reject` method is called. Here’s the syntax:
+当 promise 失败时会调用 `catch` 方法。 当 promise 的 `reject` 方法执行时会直接调用。 用法如下:
```js
myPromise.catch(error => {
- // do something with the error.
+
});
```
-`error` is the argument passed in to the `reject` method.
+`error` 是传入 `reject` 方法的参数。
# --instructions--
-Add the `catch` method to your promise. Use `error` as the parameter of its callback function and log `error` to the console.
+给 promise 添加 `catch` 方法。 用 `error` 作为回调函数的参数,并把 `error` 打印到控制台。
# --hints--
-You should call the `catch` method on the promise.
+应该在 promise 上调用 `catch` 方法。
```js
assert(
@@ -32,13 +32,13 @@ assert(
);
```
-Your `catch` method should have a callback function with `error` as its parameter.
+`catch` 方法应该有一个回调函数,回调函数参数为 `error`。
```js
assert(errorIsParameter);
```
-You should log `error` to the console.
+应该打印 `error` 到控制台。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/import-a-default-export.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/import-a-default-export.md
index d8a0a3d465..f14498a0bc 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/import-a-default-export.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/import-a-default-export.md
@@ -1,6 +1,6 @@
---
id: 587d7b8d367417b2b2512b59
-title: Import a Default Export
+title: 导入一个默认的导出
challengeType: 1
forumTopicId: 301205
dashedName: import-a-default-export
@@ -8,21 +8,21 @@ dashedName: import-a-default-export
# --description--
-In the last challenge, you learned about `export default` and its uses. To import a default export, you need to use a different `import` syntax. In the following example, `add` is the default export of the `math_functions.js` file. Here is how to import it:
+在上一个挑战里,学习了 `export default` 的用法。 还需要一种 `import` 的语法来导入默认的导出。 在下面的例子里,`add` 是 `math_functions.js` 文件的默认导出。 以下是如何导入它:
```js
import add from "./math_functions.js";
```
-The syntax differs in one key place. The imported value, `add`, is not surrounded by curly braces (`{}`). `add` here is simply a variable name for whatever the default export of the `math_functions.js` file is. You can use any name here when importing a default.
+这个语法有一处特别的地方, 被导入的 `add` 值没有被花括号(`{}`)所包围。 `add` 只是一个变量的名字,对应 `math_functions.js` 文件的任何默认导出值。 在导入默认导出时,可以使用任何名字。
# --instructions--
-In the following code, import the default export from the `math_functions.js` file, found in the same directory as this file. Give the import the name `subtract`.
+在下面的代码中,导入同一目录中 `math_functions.js` 文件的默认导出。 导入变量的名字为 `subtract`。
# --hints--
-You should properly import `subtract` from `math_functions.js`.
+应从 `math_functions.js` 中正确导入 `subtract`。
```js
assert(code.match(/import\s+subtract\s+from\s+('|")\.\/math_functions\.js\1/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md
index 90799c6bba..da1975e0a4 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md
@@ -1,6 +1,6 @@
---
id: 587d7b87367417b2b2512b42
-title: Mutate an Array Declared with const
+title: 改变一个用 const 声明的数组
challengeType: 1
forumTopicId: 301206
dashedName: mutate-an-array-declared-with-const
@@ -8,40 +8,42 @@ dashedName: mutate-an-array-declared-with-const
# --description--
-The `const` declaration has many use cases in modern JavaScript.
+在现代的 JavaScript 里,`const` 声明有很多用法。
-Some developers prefer to assign all their variables using `const` by default, unless they know they will need to reassign the value. Only in that case, they use `let`.
+一些开发者倾向于默认使用 `const` 来声明所有变量,除非他们打算后续重新给变量赋值, 那么他们在声明的时候就会用 `let`。
-However, it is important to understand that objects (including arrays and functions) assigned to a variable using `const` are still mutable. Using the `const` declaration only prevents reassignment of the variable identifier.
+然而,你要注意,对象(包括数组和函数)在使用 `const` 声明的时候依然是可变的。 使用 `const` 来声明只会保证变量不会被重新赋值。
```js
const s = [5, 6, 7];
-s = [1, 2, 3]; // throws error, trying to assign a const
-s[2] = 45; // works just as it would with an array declared with var or let
-console.log(s); // returns [5, 6, 45]
+s = [1, 2, 3];
+s[2] = 45;
+console.log(s);
```
-As you can see, you can mutate the object `[5, 6, 7]` itself and the variable `s` will still point to the altered array `[5, 6, 45]`. Like all arrays, the array elements in `s` are mutable, but because `const` was used, you cannot use the variable identifier `s` to point to a different array using the assignment operator.
+`s = [1, 2, 3]` 会导致一个错误。 `console.log` 会显示值 `[5, 6, 45]`。
+
+可以发现,你可以改变对象 `[5, 6, 7]` 本身,而变量 `s` 会指向改变后的数组 `[5, 6, 45]`。 和所有数组一样,数组 `s` 中的元素是可以被改变的,但是因为使用了 `const` 关键字,你不能使用赋值操作符将变量标识 `s` 指向另外一个数组。
# --instructions--
-An array is declared as `const s = [5, 7, 2]`. Change the array to `[2, 5, 7]` using various element assignments.
+这里有一个使用 `const s = [5, 7, 2]` 声明的数组。 使用对各元素赋值的方法将数组改成 `[2, 5, 7]`。
# --hints--
-You should not replace `const` keyword.
+不要替换 `const` 关键字。
```js
(getUserInput) => assert(getUserInput('index').match(/const/g));
```
-`s` should be a constant variable (by using `const`).
+`s` 应该为常量(使用 `const`)。
```js
(getUserInput) => assert(getUserInput('index').match(/const\s+s/g));
```
-You should not change the original array declaration.
+不要改变原数组的声明。
```js
(getUserInput) =>
@@ -52,7 +54,7 @@ You should not change the original array declaration.
);
```
-`s` should be equal to `[2, 5, 7]`.
+`s` 应该等于 `[2, 5, 7]`。
```js
assert.deepEqual(s, [2, 5, 7]);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md
index fb97d40308..356eee60c1 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/prevent-object-mutation.md
@@ -1,6 +1,6 @@
---
id: 598f48a36c8c40764b4e52b3
-title: Prevent Object Mutation
+title: 防止对象改变
challengeType: 1
forumTopicId: 301207
dashedName: prevent-object-mutation
@@ -8,9 +8,9 @@ dashedName: prevent-object-mutation
# --description--
-As seen in the previous challenge, `const` declaration alone doesn't really protect your data from mutation. To ensure your data doesn't change, JavaScript provides a function `Object.freeze` to prevent data mutation.
+通过之前的挑战可以看出,`const` 声明并不会真的保护数据不被改变。 为了确保数据不被改变,JavaScript 提供了一个函数 `Object.freeze`。
-Once the object is frozen, you can no longer add, update, or delete properties from it. Any attempt at changing the object will be rejected without an error.
+当一个对象被冻结的时候,你不能再对它的属性再进行增、删、改的操作。 任何试图改变对象的操作都会被阻止,却不会报错。
```js
let obj = {
@@ -18,32 +18,33 @@ let obj = {
review:"Awesome"
};
Object.freeze(obj);
-obj.review = "bad"; // will be ignored. Mutation not allowed
-obj.newProp = "Test"; // will be ignored. Mutation not allowed
+obj.review = "bad";
+obj.newProp = "Test";
console.log(obj);
-// { name: "FreeCodeCamp", review:"Awesome"}
```
+`obj.review` 和 `obj.newProp` 赋值将导致错误,控制台将显示值 `{ name: "FreeCodeCamp", review: "Awesome" }`。
+
# --instructions--
-In this challenge you are going to use `Object.freeze` to prevent mathematical constants from changing. You need to freeze the `MATH_CONSTANTS` object so that no one is able to alter the value of `PI`, add, or delete properties.
+在这个挑战中,你将使用 `Object.freeze` 来防止数学常量被改变。 你需要冻结 `MATH_CONSTANTS` 对象,使得没有人可以改变 `PI` 的值,或增加或删除属性。
# --hints--
-You should not replace `const` keyword.
+不要替换 `const` 关键字。
```js
(getUserInput) => assert(getUserInput('index').match(/const/g));
```
-`MATH_CONSTANTS` should be a constant variable (by using `const`).
+`MATH_CONSTANTS` 应该为一个常量(使用 `const`)。
```js
(getUserInput) =>
assert(getUserInput('index').match(/const\s+MATH_CONSTANTS/g));
```
-You should not change original `MATH_CONSTANTS`.
+不要改变 `MATH_CONSTANTS` 的原始声明。
```js
(getUserInput) =>
@@ -54,7 +55,7 @@ You should not change original `MATH_CONSTANTS`.
);
```
-`PI` should equal `3.14`.
+`PI` 应等于 `3.14`。
```js
assert(PI === 3.14);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/reuse-javascript-code-using-import.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/reuse-javascript-code-using-import.md
index ff3449dd2f..7b68385b12 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/reuse-javascript-code-using-import.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/reuse-javascript-code-using-import.md
@@ -1,6 +1,6 @@
---
id: 587d7b8c367417b2b2512b55
-title: Reuse JavaScript Code Using import
+title: 通过 import 复用 JavaScript 代码
challengeType: 1
forumTopicId: 301208
dashedName: reuse-javascript-code-using-import
@@ -8,15 +8,15 @@ dashedName: reuse-javascript-code-using-import
# --description--
-`import` allows you to choose which parts of a file or module to load. In the previous lesson, the examples exported `add` from the `math_functions.js` file. Here's how you can import it to use in another file:
+`import` 可以导入文件或模块的一部分。 在之前的课程里,例子从 `math_functions.js` 文件里导出了 `add`。 下面看一下如何在其它文件导入它:
```js
import { add } from './math_functions.js';
```
-Here, `import` will find `add` in `math_functions.js`, import just that function for you to use, and ignore the rest. The `./` tells the import to look for the `math_functions.js` file in the same folder as the current file. The relative file path (`./`) and file extension (`.js`) are required when using import in this way.
+在这里,`import` 会在 `math_functions.js` 里找到 `add`,只导入这个函数,忽略剩余的部分。 `./` 告诉程序在当前文件的相同目录寻找 `math_functions.js` 文件。 用这种方式导入时,相对路径(`./`)和文件扩展名(`.js`)都是必需的。
-You can import more than one item from the file by adding them in the `import` statement like this:
+通过在 `import` 语句里添加项目,可以从文件里导入多个项目,如下:
```js
import { add, subtract } from './math_functions.js';
@@ -24,11 +24,11 @@ import { add, subtract } from './math_functions.js';
# --instructions--
-Add the appropriate `import` statement that will allow the current file to use the `uppercaseString` and `lowercaseString` functions you exported in the previous lesson. These functions are in a file called `string_functions.js`, which is in the same directory as the current file.
+添加 `import` 语句,使当前文件可以使用你在之前课程里导出的 `uppercaseString` 和 `lowercaseString` 函数。 函数在当前路径下的 `string_functions.js` 文件里。
# --hints--
-You should properly import `uppercaseString`.
+应该导入 `uppercaseString`。
```js
assert(
@@ -38,7 +38,7 @@ assert(
);
```
-You should properly import `lowercaseString`.
+应该导入 `lowercaseString`。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions.md
index b804b67af1..753d97b180 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions.md
@@ -1,6 +1,6 @@
---
id: 587d7b88367417b2b2512b46
-title: Set Default Parameters for Your Functions
+title: 设置函数的默认参数
challengeType: 1
forumTopicId: 301209
dashedName: set-default-parameters-for-your-functions
@@ -8,38 +8,40 @@ dashedName: set-default-parameters-for-your-functions
# --description--
-In order to help us create more flexible functions, ES6 introduces default parameters for functions.
+ES6 里允许给函数传入默认参数,来构建更加灵活的函数。
-Check out this code:
+请看以下代码:
```js
const greeting = (name = "Anonymous") => "Hello " + name;
-console.log(greeting("John")); // Hello John
-console.log(greeting()); // Hello Anonymous
+console.log(greeting("John"));
+console.log(greeting());
```
-The default parameter kicks in when the argument is not specified (it is undefined). As you can see in the example above, the parameter `name` will receive its default value `"Anonymous"` when you do not provide a value for the parameter. You can add default values for as many parameters as you want.
+控制台将显示字符串 `Hello John` 和 `Hello Anonymous`。
+
+默认参数会在参数没有被指定(值为 undefined)的时候起作用。 在上面的例子中,参数 `name` 会在没有得到新的值的时候,默认使用值 `Anonymous`。 你还可以给多个参数赋予默认值。
# --instructions--
-Modify the function `increment` by adding default parameters so that it will add 1 to `number` if `value` is not specified.
+给函数 `increment` 加上默认参数,使得在 `value` 没有被赋值的时候,默认给 `number` 加上 1。
# --hints--
-The result of `increment(5, 2)` should be `7`.
+`increment(5, 2)` 的结果应该是 `7`。
```js
assert(increment(5, 2) === 7);
```
-The result of `increment(5)` should be `6`.
+`increment(5)` 的结果应该是 `6`。
```js
assert(increment(5) === 6);
```
-A default parameter value of `1` should be used for `value`.
+参数 `value` 的默认值是 `1`。
```js
assert(code.match(/value\s*=\s*1/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file.md
index a175f32383..8abbb1f7fa 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use--to-import-everything-from-a-file.md
@@ -1,6 +1,6 @@
---
id: 587d7b8c367417b2b2512b57
-title: Use * to Import Everything from a File
+title: 用 * 从文件中导入所有内容
challengeType: 1
forumTopicId: 301210
dashedName: use--to-import-everything-from-a-file
@@ -8,13 +8,13 @@ dashedName: use--to-import-everything-from-a-file
# --description--
-Suppose you have a file and you wish to import all of its contents into the current file. This can be done with the `import * as` syntax. Here's an example where the contents of a file named `math_functions.js` are imported into a file in the same directory:
+假设你有一个文件,你希望将其所有内容导入到当前文件中。 可以用 `import * as` 语法来实现。 下面是一个从同目录下的 `math_functions.js` 文件中导入所有内容的例子:
```js
import * as myMathModule from "./math_functions.js";
```
-The above `import` statement will create an object called `myMathModule`. This is just a variable name, you can name it anything. The object will contain all of the exports from `math_functions.js` in it, so you can access the functions like you would any other object property. Here's how you can use the `add` and `subtract` functions that were imported:
+上面的 `import` 语句会创建一个叫作 `myMathModule` 的对象。 这只是一个变量名,可以随便命名。 对象包含 `math_functions.js` 文件里的所有导出,可以像访问对象的属性那样访问里面的函数。 下面是使用导入的 `add` 和 `subtract` 函数的例子:
```js
myMathModule.add(2,3);
@@ -23,11 +23,11 @@ myMathModule.subtract(5,3);
# --instructions--
-The code in this file requires the contents of the file: `string_functions.js`, that is in the same directory as the current file. Use the `import * as` syntax to import everything from the file into an object called `stringFunctions`.
+下面的代码需要从同目录下的 `string_functions.js` 文件中导入所有内容。 使用 `import * as` 语法将文件的所有内容导入对象 `stringFunctions`。
# --hints--
-Your code should properly use `import * as` syntax.
+正确使用 `import * as` 语法。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-arrow-functions-to-write-concise-anonymous-functions.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-arrow-functions-to-write-concise-anonymous-functions.md
index b1e92a91d2..3130b7d1b9 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-arrow-functions-to-write-concise-anonymous-functions.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-arrow-functions-to-write-concise-anonymous-functions.md
@@ -1,6 +1,6 @@
---
id: 587d7b87367417b2b2512b43
-title: Use Arrow Functions to Write Concise Anonymous Functions
+title: 使用箭头函数编写简洁的匿名函数
challengeType: 1
forumTopicId: 301211
dashedName: use-arrow-functions-to-write-concise-anonymous-functions
@@ -8,9 +8,9 @@ dashedName: use-arrow-functions-to-write-concise-anonymous-functions
# --description--
-In JavaScript, we often don't need to name our functions, especially when passing a function as an argument to another function. Instead, we create inline functions. We don't need to name these functions because we do not reuse them anywhere else.
+在 JavaScript 里,我们会经常遇到不需要给函数命名的情况,尤其是在需要将一个函数作为参数传给另外一个函数的时候。 这时,我们会创建匿名函数。 因为这些函数不会在其他地方复用,所以我们不需要给它们命名。
-To achieve this, we often use the following syntax:
+这种情况下,我们通常会使用以下语法:
```js
const myFunc = function() {
@@ -19,7 +19,7 @@ const myFunc = function() {
}
```
-ES6 provides us with the syntactic sugar to not have to write anonymous functions this way. Instead, you can use **arrow function syntax**:
+ES6 提供了其他写匿名函数的方式的语法糖。 你可以使用**箭头函数**:
```js
const myFunc = () => {
@@ -28,45 +28,45 @@ const myFunc = () => {
}
```
-When there is no function body, and only a return value, arrow function syntax allows you to omit the keyword `return` as well as the brackets surrounding the code. This helps simplify smaller functions into one-line statements:
+当不需要函数体,只返回一个值的时候,箭头函数允许你省略 `return` 关键字和外面的大括号。 这样就可以将一个简单的函数简化成一个单行语句。
```js
const myFunc = () => "value";
```
-This code will still return the string `value` by default.
+这段代码默认会返回字符串 `value`。
# --instructions--
-Rewrite the function assigned to the variable `magic` which returns a `new Date()` to use arrow function syntax. Also, make sure nothing is defined using the keyword `var`.
+使用箭头函数的语法重写赋给 `magic` 变量的函数,使其返回一个新的 Date() `new Date()`。 同时不要用 `var` 关键字来定义任何变量。
# --hints--
-User should replace `var` keyword.
+应该替换 `var` 关键字。
```js
(getUserInput) => assert(!getUserInput('index').match(/var/g));
```
-`magic` should be a constant variable (by using `const`).
+`magic` 应该为一个常量(使用 `const`)。
```js
(getUserInput) => assert(getUserInput('index').match(/const\s+magic/g));
```
-`magic` should be a `function`.
+`magic` 应该是一个函数 `function`。
```js
assert(typeof magic === 'function');
```
-`magic()` should return correct date.
+`magic()` 应该返回正确的日期。
```js
assert(magic().setHours(0, 0, 0, 0) === new Date().setHours(0, 0, 0, 0));
```
-`function` keyword should not be used.
+不要使用 `function` 关键字。
```js
(getUserInput) => assert(!getUserInput('index').match(/function/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function.md
index 9e27796ab3..636aedb488 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function.md
@@ -1,6 +1,6 @@
---
id: 587d7b8b367417b2b2512b53
-title: Use class Syntax to Define a Constructor Function
+title: 使用 class 语法定义构造函数
challengeType: 1
forumTopicId: 301212
dashedName: use-class-syntax-to-define-a-constructor-function
@@ -8,11 +8,11 @@ dashedName: use-class-syntax-to-define-a-constructor-function
# --description--
-ES6 provides a new syntax to create objects, using the class keyword.
+ES6 提供了一个新的创建对象的语法,使用关键字 class。
-It should be noted that the `class` syntax is just syntax, and not a full-fledged class-based implementation of an object-oriented paradigm, unlike in languages such as Java, Python, Ruby, etc.
+值得注意的是,`class` 只是一个语法糖,它并不像 Java、Python 或者 Ruby 这一类的语言一样,严格履行了面向对象的开发规范。
-In ES5, we usually define a constructor function and use the `new` keyword to instantiate an object.
+在 ES5 里面,我们通常会定义一个构造函数 `constructor`,然后使用 `new` 关键字来实例化一个对象:
```js
var SpaceShuttle = function(targetPlanet){
@@ -21,7 +21,7 @@ var SpaceShuttle = function(targetPlanet){
var zeus = new SpaceShuttle('Jupiter');
```
-The `class` syntax simply replaces the constructor function creation:
+`class` 语法只是简单地替换了构造函数 `constructor` 的写法:
```js
class SpaceShuttle {
@@ -32,21 +32,21 @@ class SpaceShuttle {
const zeus = new SpaceShuttle('Jupiter');
```
-It should be noted that the `class` keyword declares a new function, to which a constructor is added. This constructor is invoked when `new` is called to create a new object.
-**Notes:**
+应该注意 `class` 关键字声明了一个新的函数,里面添加了一个构造函数。 当用 `new` 创建一个新的对象时,构造函数会被调用。
-- UpperCamelCase should be used by convention for ES6 class names, as in `SpaceShuttle` used above.
-- The constructor method is a special method for creating and initializing an object created with a class. You will learn more about it in the Object Oriented Programming section of the JavaScript Algorithms And Data Structures Certification.
+**注意:**首字母大写驼峰命名法 UpperCamelCase 是 ES6 class 命名的惯例,就像上面的 `SpaceShuttle`。
+
+`constructor` 方法是一个特殊方法,用于创建和初始化 class 创建的对象。 在 JavaScript 算法和数据结构认证的面向对象编程章节里会更深入介绍它。
# --instructions--
-Use the `class` keyword and write a constructor to create the `Vegetable` class.
+使用 `class` 关键词,写一个 `constructor` 来创建 `Vegetable` class。
-The `Vegetable` class allows you to create a vegetable object with a property `name` that gets passed to the constructor.
+`Vegetable` 这个 class 可以创建 vegetable 对象,这个对象拥有一个在 `constructor` 中赋值的 `name` 属性。
# --hints--
-`Vegetable` should be a `class` with a defined `constructor` method.
+`Vegetable` 应该是一个 `class`,并在其中定义了 `constructor`。
```js
assert(
@@ -54,13 +54,13 @@ assert(
);
```
-`class` keyword should be used.
+应使用 `class` 关键字。
```js
assert(code.match(/class/g));
```
-`Vegetable` should be able to be instantiated.
+`Vegetable` 可以被实例化。
```js
assert(() => {
@@ -69,7 +69,7 @@ assert(() => {
});
```
-`carrot.name` should return `carrot`.
+`carrot.name` 应该返回 `carrot`。
```js
assert(carrot.name == 'carrot');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md
index 1c13043c13..051c5a941b 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md
@@ -1,6 +1,6 @@
---
id: 587d7b89367417b2b2512b4b
-title: Use Destructuring Assignment to Assign Variables from Arrays
+title: 使用解构赋值从数组中分配变量
challengeType: 1
forumTopicId: 301213
dashedName: use-destructuring-assignment-to-assign-variables-from-arrays
@@ -8,43 +8,47 @@ dashedName: use-destructuring-assignment-to-assign-variables-from-arrays
# --description--
-ES6 makes destructuring arrays as easy as destructuring objects.
+在 ES6 里面,解构数组可以如同解构对象一样简单。
-One key difference between the spread operator and array destructuring is that the spread operator unpacks all contents of an array into a comma-separated list. Consequently, you cannot pick or choose which elements you want to assign to variables.
+与数组解构不同,数组的扩展运算会将数组里的所有内容分解成一个由逗号分隔的列表。 所以,你不能选择哪个元素来给变量赋值。
-Destructuring an array lets us do exactly that:
+而对数组进行解构却可以让我们做到这一点:
```js
const [a, b] = [1, 2, 3, 4, 5, 6];
-console.log(a, b); // 1, 2
+console.log(a, b);
```
-The variable `a` is assigned the first value of the array, and `b` is assigned the second value of the array. We can also access the value at any index in an array with destructuring by using commas to reach the desired index:
+控制台将显示 `a` 和 `b` 的值为 `1, 2`。
+
+数组的第一个值被赋值给变量 `a`,数组的第二个值被赋值给变量 `b`。 我们甚至能在数组解构中使用逗号分隔符,来获取任意一个想要的值:
```js
const [a, b,,, c] = [1, 2, 3, 4, 5, 6];
-console.log(a, b, c); // 1, 2, 5
+console.log(a, b, c);
```
+控制台将显示 `a`、`b` 和 `c` 的值为 `1, 2, 5`。
+
# --instructions--
-Use destructuring assignment to swap the values of `a` and `b` so that `a` receives the value stored in `b`, and `b` receives the value stored in `a`.
+使用数组解构来交换变量 `a` 与 `b` 的值,使 `a` 接收 `b` 的值,而 `b` 接收 `a` 的值。
# --hints--
-Value of `a` should be 6, after swapping.
+交换后,`a` 的值应该为 `6`。
```js
assert(a === 6);
```
-Value of `b` should be 8, after swapping.
+交换后,`b` 的值应该为 `8`。
```js
assert(b === 8);
```
-You should use array destructuring to swap a and b.
+应使用数组解构来交换 `a` 和 `b` 的值。
```js
assert(/\[\s*(\w)\s*,\s*(\w)\s*\]\s*=\s*\[\s*\2\s*,\s*\1\s*\]/g.test(code));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md
index 23f5ff9888..7c5f5bd338 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects.md
@@ -1,6 +1,6 @@
---
id: 587d7b89367417b2b2512b4a
-title: Use Destructuring Assignment to Assign Variables from Nested Objects
+title: 使用解构赋值从嵌套对象中分配变量
challengeType: 1
forumTopicId: 301214
dashedName: use-destructuring-assignment-to-assign-variables-from-nested-objects
@@ -8,9 +8,9 @@ dashedName: use-destructuring-assignment-to-assign-variables-from-nested-objects
# --description--
-You can use the same principles from the previous two lessons to destructure values from nested objects.
+你可以使用前两节课程中相同的原则来解构嵌套对象中的值。
-Using an object similar to previous examples:
+使用与前面的例子中类似的对象:
```js
const user = {
@@ -21,13 +21,13 @@ const user = {
};
```
-Here's how to extract the values of object properties and assign them to variables with the same name:
+这是解构对象的属性值赋值给具有相同名字的变量:
```js
const { johnDoe: { age, email }} = user;
```
-And here's how you can assign an object properties' values to variables with different names:
+这是将对象的属性值赋值给具有不同名字的变量:
```js
const { johnDoe: { age: userAge, email: userEmail }} = user;
@@ -35,11 +35,11 @@ const { johnDoe: { age: userAge, email: userEmail }} = user;
# --instructions--
-Replace the two assignments with an equivalent destructuring assignment. It should still assign the variables `lowToday` and `highToday` the values of `today.low` and `today.high` from the `LOCAL_FORECAST` object.
+将两个赋值语句替换成等价的解构赋值。 `lowToday` 和 `highToday` 应该为 `LOCAL_FORECAST` 中 `today.low` 和 `today.high` 的值。
# --hints--
-You should remove the ES5 assignment syntax.
+不能使用 ES5 的赋值语句。
```js
assert(
@@ -48,7 +48,7 @@ assert(
);
```
-You should use destructuring to create the `lowToday` variable.
+应该使用解构创建 `lowToday` 变量。
```js
assert(
@@ -58,7 +58,7 @@ assert(
);
```
-You should use destructuring to create the `highToday` variable.
+应该使用解构创建 `highToday` 变量。
```js
assert(
@@ -68,7 +68,7 @@ assert(
);
```
-`lowToday` should be equal to `64` and `highToday` should be equal to `77`.
+`lowToday` 应等于 `64`,`highToday` 应等于 `77`。
```js
assert(lowToday === 64 && highToday === 77);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.md
index c0689cacb3..eb67e8b6ec 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects.md
@@ -1,6 +1,6 @@
---
id: 587d7b89367417b2b2512b49
-title: Use Destructuring Assignment to Assign Variables from Objects
+title: 使用解构赋值从对象中分配变量
challengeType: 1
forumTopicId: 301215
dashedName: use-destructuring-assignment-to-assign-variables-from-objects
@@ -8,30 +8,29 @@ dashedName: use-destructuring-assignment-to-assign-variables-from-objects
# --description--
-Destructuring allows you to assign a new variable name when extracting values. You can do this by putting the new name after a colon when assigning the value.
+可以给解构的值赋予一个新的变量名, 通过在赋值的时候将新的变量名放在冒号后面来实现。
-Using the same object from the last example:
+还是以上个例子的对象来举例:
```js
const user = { name: 'John Doe', age: 34 };
```
-Here's how you can give new variable names in the assignment:
+这是指定新的变量名的例子:
```js
const { name: userName, age: userAge } = user;
-// userName = 'John Doe', userAge = 34
```
-You may read it as "get the value of `user.name` and assign it to a new variable named `userName`" and so on.
+你可以这么理解这段代码:获取 `user.name` 的值,将它赋给一个新的变量 `userName`,等等。 `userName` 的值将是字符串 `John Doe`,`userAge` 的值将是数字 `34`。
# --instructions--
-Replace the two assignments with an equivalent destructuring assignment. It should still assign the variables `highToday` and `highTomorrow` the values of `today` and `tomorrow` from the `HIGH_TEMPERATURES` object.
+使用解构赋值语句替换两个赋值语句。 将 `HIGH_TEMPERATURES` 的 `today` 和 `tomorrow` 的值赋值给 `highToday` 和 `highTomorrow`。
# --hints--
-You should remove the ES5 assignment syntax.
+应该移除 ES5 赋值语句。
```js
assert(
@@ -40,7 +39,7 @@ assert(
);
```
-You should use destructuring to create the `highToday` variable.
+应该使用解构赋值语句创建 `highToday` 变量。
```js
assert(
@@ -50,7 +49,7 @@ assert(
);
```
-You should use destructuring to create the `highTomorrow` variable.
+应该使用解构赋值语句创建 `highTomorrow` 变量。
```js
assert(
@@ -60,7 +59,7 @@ assert(
);
```
-`highToday` should be equal to `77` and `highTomorrow` should be equal to `80`.
+`highToday` 应该等于 `77`,`highTomorrow` 应该等于 `80`。
```js
assert(highToday === 77 && highTomorrow === 80);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.md
index ec873a1fa2..5b8ac905e5 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-extract-values-from-objects.md
@@ -1,6 +1,6 @@
---
id: 5cfa550e84205a357704ccb6
-title: Use Destructuring Assignment to Extract Values from Objects
+title: 使用解构赋值来获取对象的值
challengeType: 1
forumTopicId: 301216
dashedName: use-destructuring-assignment-to-extract-values-from-objects
@@ -8,35 +8,38 @@ dashedName: use-destructuring-assignment-to-extract-values-from-objects
# --description--
-Destructuring assignment is special syntax introduced in ES6, for neatly assigning values taken directly from an object.
+解构赋值是 ES6 引入的新语法,用来从数组和对象中提取值,并优雅地对变量进行赋值。
-Consider the following ES5 code:
+有如下 ES5 代码:
```js
const user = { name: 'John Doe', age: 34 };
-const name = user.name; // name = 'John Doe'
-const age = user.age; // age = 34
+const name = user.name;
+const age = user.age;
```
-Here's an equivalent assignment statement using the ES6 destructuring syntax:
+`name` 的值应该是字符串 `John Doe`, `age` 的值应该是数字 `34`。
+
+下面是使用 ES6 解构赋值语句,实现相同效果:
```js
const { name, age } = user;
-// name = 'John Doe', age = 34
```
-Here, the `name` and `age` variables will be created and assigned the values of their respective values from the `user` object. You can see how much cleaner this is.
+同样,`name` 的值应该是字符串 `John Doe`, `age` 的值应该是数字 `34`。
-You can extract as many or few values from the object as you want.
+在这里,自动创建 `name` 和 `age` 变量,并将 `user` 对象相应属性的值赋值给它们。 这个方法简洁多了。
+
+你可以从对象中提取尽可能多或很少的值。
# --instructions--
-Replace the two assignments with an equivalent destructuring assignment. It should still assign the variables `today` and `tomorrow` the values of `today` and `tomorrow` from the `HIGH_TEMPERATURES` object.
+把两个赋值语句替换成效果相同的解构赋值语句。 `today` 和 `tomorrow` 的值应该还是 `HIGH_TEMPERATURES` 对象中 `today` 和 `tomorrow` 属性的值。
# --hints--
-You should remove the ES5 assignment syntax.
+应该移除 ES5 赋值语句。
```js
assert(
@@ -46,7 +49,7 @@ assert(
);
```
-You should use destructuring to create the `today` variable.
+应该使用解构赋值创建 `today` 变量。
```js
assert(
@@ -58,7 +61,7 @@ assert(
);
```
-You should use destructuring to create the `tomorrow` variable.
+应该使用解构赋值创建 `tomorrow` 变量。
```js
assert(
@@ -70,7 +73,7 @@ assert(
);
```
-`today` should be equal to `77` and `tomorrow` should be equal to `80`.
+`today` 应该等于 `77`,`tomorrow` 应该等于 `80`。
```js
assert(today === 77 && tomorrow === 80);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.md
index b142b79a75..2b32c69e42 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters.md
@@ -1,6 +1,6 @@
---
id: 587d7b8a367417b2b2512b4d
-title: Use Destructuring Assignment to Pass an Object as a Function's Parameters
+title: 使用解构赋值将对象作为函数的参数传递
challengeType: 1
forumTopicId: 301217
dashedName: use-destructuring-assignment-to-pass-an-object-as-a-functions-parameters
@@ -8,52 +8,52 @@ dashedName: use-destructuring-assignment-to-pass-an-object-as-a-functions-parame
# --description--
-In some cases, you can destructure the object in a function argument itself.
+在某些情况下,你可以在函数的参数里直接解构对象。
-Consider the code below:
+请看以下代码:
```js
const profileUpdate = (profileData) => {
const { name, age, nationality, location } = profileData;
- // do something with these variables
+
}
```
-This effectively destructures the object sent into the function. This can also be done in-place:
+上面的操作解构了传给函数的对象。 这样的操作也可以直接在参数里完成:
```js
const profileUpdate = ({ name, age, nationality, location }) => {
- /* do something with these fields */
+
}
```
-When `profileData` is passed to the above function, the values are destructured from the function parameter for use within the function.
+当 `profileData` 被传递到上面的函数时,从函数参数中解构出值以在函数内使用。
# --instructions--
-Use destructuring assignment within the argument to the function `half` to send only `max` and `min` inside the function.
+对 `half` 的参数进行解构赋值,仅将 `max` 与 `min` 的值传进函数。
# --hints--
-`stats` should be an `object`.
+`stats` 的类型应该是一个 `object`。
```js
assert(typeof stats === 'object');
```
-`half(stats)` should be `28.015`
+`half(stats)` 应该等于 `28.015`。
```js
assert(half(stats) === 28.015);
```
-Destructuring should be used.
+应该使用解构赋值。
```js
assert(__helpers.removeWhiteSpace(code).match(/half=\({\w+,\w+}\)/));
```
-Destructured parameter should be used.
+应该使用解构参数。
```js
assert(!code.match(/stats\.max|stats\.min/));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md
index 47b00256aa..5cb8814562 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-parameter-to-reassign-array-elements.md
@@ -1,7 +1,7 @@
---
id: 587d7b8a367417b2b2512b4c
title: >-
- Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
+ 使用解构赋值配合 rest 操作符来重新分配数组元素
challengeType: 1
forumTopicId: 301218
dashedName: >-
@@ -10,43 +10,45 @@ dashedName: >-
# --description--
-In some situations involving array destructuring, we might want to collect the rest of the elements into a separate array.
+在解构数组的某些情况下,我们可能希望将剩下的元素放进另一个数组里面。
-The result is similar to `Array.prototype.slice()`, as shown below:
+以下代码的结果与使用 `Array.prototype.slice()` 类似:
```js
const [a, b, ...arr] = [1, 2, 3, 4, 5, 7];
-console.log(a, b); // 1, 2
-console.log(arr); // [3, 4, 5, 7]
+console.log(a, b);
+console.log(arr);
```
-Variables `a` and `b` take the first and second values from the array. After that, because of the rest parameter's presence, `arr` gets the rest of the values in the form of an array. The rest element only works correctly as the last variable in the list. As in, you cannot use the rest parameter to catch a subarray that leaves out the last element of the original array.
+控制台将显示 `1, 2` 和 `[3, 4, 5, 7]`。
+
+变量 `a` 和 `b` 分别接收数组的第一个和第二个值。 之后,因为 rest 操作符的存在,`arr` 获取了原数组剩余的元素的值。 rest 操作符只能对数组列表最后的元素起作用。 这意味着你不能使用 rest 操作符来截取原数组中间的元素作为子数组。
# --instructions--
-Use destructuring assignment with the rest parameter to perform an effective `Array.prototype.slice()` so that `arr` is a sub-array of the original array `source` with the first two elements omitted.
+使用解构赋值以及 rest 操作符来进行和 `Array.prototype.slice()` 相同的操作,使 `arr` 是原数组 `source` 除开前两个元素的子数组。
# --hints--
-`arr` should be `[3,4,5,6,7,8,9,10]`
+`arr` 应该是 `[3,4,5,6,7,8,9,10]`。
```js
assert(arr.every((v, i) => v === i + 3) && arr.length === 8);
```
-`source` should be `[1,2,3,4,5,6,7,8,9,10]`
+`source` 应该是 `[1,2,3,4,5,6,7,8,9,10]`。
```js
assert(source.every((v, i) => v === i + 1) && source.length === 10);
```
-`Array.slice()` should not be used.
+不应该使用 `Array.slice()`。
```js
(getUserInput) => assert(!getUserInput('index').match(/slice/g));
```
-Destructuring on `list` should be used.
+应该对 `list` 进行解构赋值。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.md
index cffcbbe642..17fdb5c057 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-export-to-share-a-code-block.md
@@ -1,6 +1,6 @@
---
id: 587d7b8c367417b2b2512b56
-title: Use export to Share a Code Block
+title: 用 export 来重用代码块
challengeType: 1
forumTopicId: 301219
dashedName: use-export-to-share-a-code-block
@@ -8,7 +8,7 @@ dashedName: use-export-to-share-a-code-block
# --description--
-Imagine a file called `math_functions.js` that contains several functions related to mathematical operations. One of them is stored in a variable, `add`, that takes in two numbers and returns their sum. You want to use this function in several different JavaScript files. In order to share it with these other files, you first need to `export` it.
+假设有一个文件 `math_functions.js`,该文件包含了数学运算相关的一些函数。 其中一个存储在变量 `add` 里,该函数接受两个数字作为参数返回它们的和。 你想在几个不同的 JavaScript 文件中使用这个函数。 要实现这个目的,就需要 `export` 它。
```js
export const add = (x, y) => {
@@ -16,7 +16,7 @@ export const add = (x, y) => {
}
```
-The above is a common way to export a single function, but you can achieve the same thing like this:
+上面是导出单个函数常用方法,还可以这样导出:
```js
const add = (x, y) => {
@@ -26,7 +26,7 @@ const add = (x, y) => {
export { add };
```
-When you export a variable or function, you can import it in another file and use it without having to rewrite the code. You can export multiple things by repeating the first example for each thing you want to export, or by placing them all in the export statement of the second example, like this:
+导出变量和函数后,就可以在其它文件里导入使用从而避免了代码冗余。 重复第一个例子的代码可以导出多个对象或函数,在第二个例子里面的导出语句中添加更多值也可以导出多项,例子如下:
```js
export { add, subtract };
@@ -34,11 +34,11 @@ export { add, subtract };
# --instructions--
-There are two string-related functions in the editor. Export both of them using the method of your choice.
+编辑框中有两个字符串相关的函数。 选用一种方法导出两个函数。
# --hints--
-You should properly export `uppercaseString`.
+应该导出 `uppercaseString` 变量。
```js
assert(
@@ -48,7 +48,7 @@ assert(
);
```
-You should properly export `lowercaseString`.
+应该导出 `lowercaseString` 变量。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object.md
index 04e7ec825a..b5b965af46 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object.md
@@ -1,6 +1,6 @@
---
id: 587d7b8c367417b2b2512b54
-title: Use getters and setters to Control Access to an Object
+title: 使用 getter 和 setter 来控制对象的访问
challengeType: 1
forumTopicId: 301220
dashedName: use-getters-and-setters-to-control-access-to-an-object
@@ -8,13 +8,13 @@ dashedName: use-getters-and-setters-to-control-access-to-an-object
# --description--
-You can obtain values from an object and set the value of a property within an object.
+你可以从对象中获得一个值,也可以给对象的属性赋值。
-These are classically called getters and setters.
+这些操作通常被称为 getters 以及 setters。
-Getter functions are meant to simply return (get) the value of an object's private variable to the user without the user directly accessing the private variable.
+Getter 函数的作用是可以让对象返回一个私有变量,而不需要直接去访问私有变量。
-Setter functions are meant to modify (set) the value of an object's private variable based on the value passed into the setter function. This change could involve calculations, or even overwriting the previous value completely.
+Setter 函数的作用是可以基于传进的参数来修改对象中私有变量。 这些修改可以是计算,或者是直接替换之前的值。
```js
class Book {
@@ -31,30 +31,34 @@ class Book {
}
}
const novel = new Book('anonymous');
-console.log(novel.writer); // anonymous
+console.log(novel.writer);
novel.writer = 'newAuthor';
-console.log(novel.writer); // newAuthor
+console.log(novel.writer);
```
-Notice the syntax used to invoke the getter and setter. They do not even look like functions. Getters and setters are important because they hide internal implementation details. **Note:** It is convention to precede the name of a private variable with an underscore (`_`). However, the practice itself does not make a variable private.
+控制台将显示字符串 `anonymous` 和 `newAuthor`。
+
+请注意用于调用 getter 和 setter 的语法。 它们甚至看起来不像是函数。 getter 和 setter 非常重要,因为它们隐藏了内部的实现细节。
+
+**注意:**通常会在私有变量前添加下划线(`_`)。 然而,这种做法本身并不是将变量变成私有的。
# --instructions--
-Use the `class` keyword to create a Thermostat class. The constructor accepts a Fahrenheit temperature.
+使用 `class` 关键字创建一个 `Thermostat` class。 `constructor` 接收一个华氏温度。
-In the class, create a `getter` to obtain the temperature in Celsius and a `setter` to set the temperature in Celsius.
+在 class 中,创建一个 `getter` 来获取摄氏温度和一个 `setter` 来设置温度值。
-Remember that `C = 5/9 * (F - 32)` and `F = C * 9.0 / 5 + 32`, where `F` is the value of temperature in Fahrenheit, and `C` is the value of the same temperature in Celsius.
+记得在 `C = 5/9 * (F - 32)` 和 `F = C * 9.0 / 5 + 32` 中,`F` 是华氏温度值,`C` 是摄氏温度值。
-**Note:** When you implement this, you will track the temperature inside the class in one scale, either Fahrenheit or Celsius.
+**注意:**完成这个挑战后,应该在 class 中使用一个温度标准,要么是华氏温度,要么是摄氏温度。
-This is the power of a getter and a setter. You are creating an API for another user, who can get the correct result regardless of which one you track.
+这就是 getter 和 setter 的功能。 你正在为别的用户创建一个 API,不论你使用哪一个,用户都将获得正确的结果。
-In other words, you are abstracting implementation details from the user.
+或者说,你从用户需求中抽象出了实现细节。
# --hints--
-`Thermostat` should be a `class` with a defined `constructor` method.
+`Thermostat` 应该是一个具有 `constructor` 方法的 `class`。
```js
assert(
@@ -63,13 +67,13 @@ assert(
);
```
-`class` keyword should be used.
+应该使用 `class` 关键词。
```js
assert(code.match(/class/g));
```
-`Thermostat` should be able to be instantiated.
+`Thermostat` 应该可以被实例化。
```js
assert(
@@ -80,7 +84,7 @@ assert(
);
```
-When instantiated with a Fahrenheit value, `Thermostat` should set the correct temperature.
+当实例化华氏温度值时,`Thermostat` 应该被设置为正确的 `temperature`。
```js
assert(
@@ -91,7 +95,7 @@ assert(
);
```
-A `getter` should be defined.
+应该定义一个 `getter`。
```js
assert(
@@ -105,7 +109,7 @@ assert(
);
```
-A `setter` should be defined.
+应该定义一个 `setter`。
```js
assert(
@@ -119,7 +123,7 @@ assert(
);
```
-Calling the `setter` with a Celsius value should set the temperature.
+调用带有摄氏温度值的 `setter` 应该设置 `temperature`。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.md
index 888e68da6b..60f7d5280b 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-the-rest-parameter-with-function-parameters.md
@@ -1,6 +1,6 @@
---
id: 587d7b88367417b2b2512b47
-title: Use the Rest Parameter with Function Parameters
+title: 将 rest 操作符与函数参数一起使用
challengeType: 1
forumTopicId: 301221
dashedName: use-the-rest-parameter-with-function-parameters
@@ -8,51 +8,53 @@ dashedName: use-the-rest-parameter-with-function-parameters
# --description--
-In order to help us create more flexible functions, ES6 introduces the rest parameter for function parameters. With the rest parameter, you can create functions that take a variable number of arguments. These arguments are stored in an array that can be accessed later from inside the function.
+ES6 推出了用于函数参数的 rest 操作符帮助我们创建更加灵活的函数。 rest 操作符可以用于创建有一个变量来接受多个参数的函数。 这些参数被储存在一个可以在函数内部读取的数组中。
-Check out this code:
+请看以下代码:
```js
function howMany(...args) {
return "You have passed " + args.length + " arguments.";
}
-console.log(howMany(0, 1, 2)); // You have passed 3 arguments.
-console.log(howMany("string", null, [1, 2, 3], { })); // You have passed 4 arguments.
+console.log(howMany(0, 1, 2));
+console.log(howMany("string", null, [1, 2, 3], { }));
```
-The rest parameter eliminates the need to check the `args` array and allows us to apply `map()`, `filter()` and `reduce()` on the parameters array.
+控制台将显示字符串 `You have passed 3 arguments.` 和 `You have passed 4 arguments.`。
+
+使用 rest 参数,就不需要查看 `args` 数组,并且允许我们在参数数组上使用 `map()`、`filter()` 和 `reduce()`。
# --instructions--
-Modify the function `sum` using the rest parameter in such a way that the function `sum` is able to take any number of arguments and return their sum.
+修改 `sum` 函数,使用 rest 参数,使 `sum` 函数可以接收任意数量的参数,并返回它们的总和。
# --hints--
-The result of `sum(0,1,2)` should be 3
+`sum(0,1,2)` 的结果应是 3。
```js
assert(sum(0, 1, 2) === 3);
```
-The result of `sum(1,2,3,4)` should be 10
+`sum(1,2,3,4)` 的结果应是 10。
```js
assert(sum(1, 2, 3, 4) === 10);
```
-The result of `sum(5)` should be 5
+`sum(5)` 的结果应是 5。
```js
assert(sum(5) === 5);
```
-The result of `sum()` should be 0
+`sum()` 的结果应是 0。
```js
assert(sum() === 0);
```
-`sum` should be an arrow function which uses the rest parameter syntax (`...`) on the `args` parameter.
+`sum` 应是一个箭头函数,对 `args` 参数使用 rest 操作符语法(`...`)。
```js
assert(__helpers.removeWhiteSpace(code).match(/sum=\(\.\.\.args\)=>/));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place.md
index 9fa3b6b1b5..5412467732 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/use-the-spread-operator-to-evaluate-arrays-in-place.md
@@ -1,6 +1,6 @@
---
id: 587d7b89367417b2b2512b48
-title: Use the Spread Operator to Evaluate Arrays In-Place
+title: 使用 spread 运算符展开数组项
challengeType: 1
forumTopicId: 301222
dashedName: use-the-spread-operator-to-evaluate-arrays-in-place
@@ -8,47 +8,51 @@ dashedName: use-the-spread-operator-to-evaluate-arrays-in-place
# --description--
-ES6 introduces the spread operator, which allows us to expand arrays and other expressions in places where multiple parameters or elements are expected.
+ES6 引入了展开操作符,可以展开数组以及需要多个参数或元素的表达式。
-The ES5 code below uses `apply()` to compute the maximum value in an array:
+下面的 ES5 代码使用了 `apply()` 来计算数组的最大值:
```js
var arr = [6, 89, 3, 45];
-var maximus = Math.max.apply(null, arr); // returns 89
+var maximus = Math.max.apply(null, arr);
```
-We had to use `Math.max.apply(null, arr)` because `Math.max(arr)` returns `NaN`. `Math.max()` expects comma-separated arguments, but not an array. The spread operator makes this syntax much better to read and maintain.
+`maximus` 的值为 `89`。
+
+我们必须使用 `Math.max.apply(null, arr)`,因为 `Math.max(arr)` 返回 `NaN`。 `Math.max()` 函数中需要传入的是一系列由逗号分隔的参数,而不是一个数组。 展开操作符可以提升代码的可读性,使代码易于维护。
```js
const arr = [6, 89, 3, 45];
-const maximus = Math.max(...arr); // returns 89
+const maximus = Math.max(...arr);
```
-`...arr` returns an unpacked array. In other words, it *spreads* the array. However, the spread operator only works in-place, like in an argument to a function or in an array literal. The following code will not work:
+`maximus` 的值应该是 `89`。
+
+`...arr` 返回一个解压的数组。 也就是说,它*展开*数组。 然而,展开操作符只能够在函数的参数中或者数组中使用。 下面的代码将会报错:
```js
-const spreaded = ...arr; // will throw a syntax error
+const spreaded = ...arr;
```
# --instructions--
-Copy all contents of `arr1` into another array `arr2` using the spread operator.
+使用展开操作符将 `arr1` 中的内容都复制到 `arr2` 中去。
# --hints--
-`arr2` should be correct copy of `arr1`.
+`arr2` 应该是从 `arr1` 复制而来。
```js
assert(arr2.every((v, i) => v === arr1[i]) && arr2.length);
```
-`...` spread operator should be used to duplicate `arr1`.
+应使用展开操作符 `...` 来复制 `arr1`。
```js
assert(code.match(/Array\(\s*\.\.\.arr1\s*\)|\[\s*\.\.\.arr1\s*\]/));
```
-`arr2` should remain unchanged when `arr1` is changed.
+当 `arr1` 改变的时候,`arr2` 应保持不变。
```js
assert((arr1, arr2) => {
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters.md
index 390cb0933c..f16e49c024 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-arrow-functions-with-parameters.md
@@ -1,6 +1,6 @@
---
id: 587d7b88367417b2b2512b44
-title: Write Arrow Functions with Parameters
+title: 编写带参数的箭头函数
challengeType: 1
forumTopicId: 301223
dashedName: write-arrow-functions-with-parameters
@@ -8,48 +8,49 @@ dashedName: write-arrow-functions-with-parameters
# --description--
-Just like a regular function, you can pass arguments into an arrow function.
+和一般的函数一样,你也可以给箭头函数传递参数。
```js
-// doubles input value and returns it
const doubler = (item) => item * 2;
-doubler(4); // returns 8
+doubler(4);
```
-If an arrow function has a single parameter, the parentheses enclosing the parameter may be omitted.
+`doubler(4)` 将返回 `8`。
+
+如果箭头函数只有一个参数,则可以省略参数外面的括号。
```js
-// the same function, without the parameter parentheses
const doubler = item => item * 2;
```
-It is possible to pass more than one argument into an arrow function.
+可以给箭头函数传递多个参数。
```js
-// multiplies the first input value by the second and returns it
const multiplier = (item, multi) => item * multi;
-multiplier(4, 2); // returns 8
+multiplier(4, 2);
```
+`multiplier(4, 2)` 将返回 `8`。
+
# --instructions--
-Rewrite the `myConcat` function which appends contents of `arr2` to `arr1` so that the function uses arrow function syntax.
+使用箭头函数的语法重写 `myConcat` 函数,将 `arr2` 的内容添加到 `arr1`。
# --hints--
-You should replace the `var` keyword.
+应替换 `var` 关键词。
```js
(getUserInput) => assert(!getUserInput('index').match(/var/g));
```
-`myConcat` should be a constant variable (by using `const`).
+`myConcat` 应该是一个常量(使用`const`)。
```js
(getUserInput) => assert(getUserInput('index').match(/const\s+myConcat/g));
```
-`myConcat` should be an arrow function with two parameters
+`myConcat` 应该是一个带有两个参数的箭头函数。
```js
assert(
@@ -58,13 +59,13 @@ assert(
);
```
-`myConcat()` should return `[1, 2, 3, 4, 5]`.
+`myConcat()` 应该返回 `[1, 2, 3, 4, 5]`。
```js
assert.deepEqual(myConcat([1, 2], [3, 4, 5]), [1, 2, 3, 4, 5]);
```
-`function` keyword should not be used.
+不能使用 `function` 关键字。
```js
(getUserInput) => assert(!getUserInput('index').match(/function/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md
index b7bd2904d8..384c805217 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-concise-declarative-functions-with-es6.md
@@ -1,6 +1,6 @@
---
id: 587d7b8b367417b2b2512b50
-title: Write Concise Declarative Functions with ES6
+title: 用 ES6 编写简洁的函数声明
challengeType: 1
forumTopicId: 301224
dashedName: write-concise-declarative-functions-with-es6
@@ -8,7 +8,7 @@ dashedName: write-concise-declarative-functions-with-es6
# --description--
-When defining functions within objects in ES5, we have to use the keyword `function` as follows:
+在 ES5 中,当我们需要在对象中定义一个函数的时候,必须像这样使用 `function` 关键字:
```js
const person = {
@@ -19,7 +19,7 @@ const person = {
};
```
-With ES6, You can remove the `function` keyword and colon altogether when defining functions in objects. Here's an example of this syntax:
+用 ES6 的语法在对象中定义函数的时候,可以删除 `function` 关键词和冒号。 请看以下例子:
```js
const person = {
@@ -32,17 +32,17 @@ const person = {
# --instructions--
-Refactor the function `setGear` inside the object `bicycle` to use the shorthand syntax described above.
+使用以上这种简短的语法,重构在 `bicycle` 对象中的 `setGear` 函数。
# --hints--
-Traditional function expression should not be used.
+不应使用传统的函数定义方法。
```js
(getUserInput) => assert(!__helpers.removeJSComments(code).match(/function/));
```
-`setGear` should be a declarative function.
+`setGear` 应是一个声明函数。
```js
assert(
@@ -50,7 +50,7 @@ assert(
);
```
-`bicycle.setGear(48)` should change the `gear` value to 48.
+`bicycle.setGear(48)` 应将 `gear` 的值改为 48。
```js
assert(new bicycle.setGear(48).gear === 48);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md
index 33dabc5d3a..6f5f00d828 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/es6/write-concise-object-literal-declarations-using-object-property-shorthand.md
@@ -1,6 +1,6 @@
---
id: 587d7b8a367417b2b2512b4f
-title: Write Concise Object Literal Declarations Using Object Property Shorthand
+title: 使用简单字段编写简洁的对象字面量声明
challengeType: 1
forumTopicId: 301225
dashedName: write-concise-object-literal-declarations-using-object-property-shorthand
@@ -8,9 +8,9 @@ dashedName: write-concise-object-literal-declarations-using-object-property-shor
# --description--
-ES6 adds some nice support for easily defining object literals.
+ES6 添加了一些很棒的功能,用于更方便地定义对象。
-Consider the following code:
+请看以下代码:
```js
const getMousePosition = (x, y) => ({
@@ -19,7 +19,7 @@ const getMousePosition = (x, y) => ({
});
```
-`getMousePosition` is a simple function that returns an object containing two properties. ES6 provides the syntactic sugar to eliminate the redundancy of having to write `x: x`. You can simply write `x` once, and it will be converted to`x: x` (or something equivalent) under the hood. Here is the same function from above rewritten to use this new syntax:
+`getMousePosition` 简单的函数,返回拥有两个属性的对象。 ES6 提供了一个语法糖,消除了类似 `x: x` 这种冗余的写法。 你可以只写一次 `x`,解释器会自动将其转换成 `x: x`(或效果相同的内容)。 下面是使用这种语法重写的同样的函数:
```js
const getMousePosition = (x, y) => ({ x, y });
@@ -27,11 +27,11 @@ const getMousePosition = (x, y) => ({ x, y });
# --instructions--
-Use object property shorthand with object literals to create and return an object with `name`, `age` and `gender` properties.
+请使用简单属性对象的语法来创建并返回一个具有 `name`、`age` 和 `gender` 属性的对象。
# --hints--
-`createPerson("Zodiac Hasbro", 56, "male")` should return `{name: "Zodiac Hasbro", age: 56, gender: "male"}`.
+`createPerson("Zodiac Hasbro", 56, "male")` 应该返回 `{name: "Zodiac Hasbro", age: 56, gender: "male"}`。
```js
assert.deepEqual(
@@ -40,7 +40,7 @@ assert.deepEqual(
);
```
-Your code should not use `key:value`.
+不要使用 `key:value`。
```js
(getUserInput) => assert(!getUserInput('index').match(/:/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/avoid-mutations-and-side-effects-using-functional-programming.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/avoid-mutations-and-side-effects-using-functional-programming.md
index 0f401beeab..deeeb4d8ea 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/avoid-mutations-and-side-effects-using-functional-programming.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/avoid-mutations-and-side-effects-using-functional-programming.md
@@ -1,6 +1,6 @@
---
id: 587d7b8e367417b2b2512b5e
-title: Avoid Mutations and Side Effects Using Functional Programming
+title: 使用函数式编程避免变化和副作用
challengeType: 1
forumTopicId: 301228
dashedName: avoid-mutations-and-side-effects-using-functional-programming
@@ -8,39 +8,39 @@ dashedName: avoid-mutations-and-side-effects-using-functional-programming
# --description--
-If you haven't already figured it out, the issue in the previous challenge was with the `splice` call in the `tabClose()` function. Unfortunately, `splice` changes the original array it is called on, so the second call to it used a modified array, and gave unexpected results.
+如果你还没想通,上一个挑战的问题出在 `tabClose()` 函数里的 `splice`。 不幸的是,`splice` 修改了调用它的原始数组,所以第二次调用它时是基于修改后的数组,才给出了意料之外的结果。
-This is a small example of a much larger pattern - you call a function on a variable, array, or an object, and the function changes the variable or something in the object.
+这是一个小例子,还有更广义的定义——在变量,数组或对象上调用一个函数,这个函数会改变对象中的变量或其他东西。
-One of the core principles of functional programming is to not change things. Changes lead to bugs. It's easier to prevent bugs knowing that your functions don't change anything, including the function arguments or any global variable.
+函数式编程的核心原则之一是不改变任何东西。 变化会导致错误。 如果一个函数不改变传入的参数、全局变量等数据,那么它造成问题的可能性就会小很多。
-The previous example didn't have any complicated operations but the `splice` method changed the original array, and resulted in a bug.
+前面的例子没有任何复杂的操作,但是 `splice` 方法改变了原始数组,导致 bug 产生。
-Recall that in functional programming, changing or altering things is called mutation, and the outcome is called a side effect. A function, ideally, should be a pure function, meaning that it does not cause any side effects.
+回想一下,在函数式编程中,改变或变更叫做 mutation,这种改变的结果叫做“副作用”(side effect)。 理想情况下,函数应该是不会产生任何副作用的 pure function。
-Let's try to master this discipline and not alter any variable or object in our code.
+让我们尝试掌握这个原则:不要改变代码中的任何变量或对象。
# --instructions--
-Fill in the code for the function `incrementer` so it returns the value of the global variable `fixedValue` increased by one.
+填写 `incrementer` 函数的代码,使其返回值为全局变量 `fixedValue` 增加 1 。
# --hints--
-Your function `incrementer` should not change the value of `fixedValue` (which is `4`).
+`incrementer` 函数不能改变 `fixedValue` 的值(`4`)。
```js
incrementer();
assert(fixedValue === 4);
```
-Your `incrementer` function should return a value that is one larger than the `fixedValue` value.
+`incrementer` 函数应返回比 `fixedValue` 变量更大的值。
```js
const __newValue = incrementer();
assert(__newValue === 5);
```
-Your `incrementer` function should return a value based on the global `fixedValue` variable value.
+你的 `incrementer` 函数返回的值应该基于全局变量 `fixedValue` 的值。
```js
(function () {
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/implement-map-on-a-prototype.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/implement-map-on-a-prototype.md
index b1098b2b28..03bc973991 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/implement-map-on-a-prototype.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/implement-map-on-a-prototype.md
@@ -1,6 +1,6 @@
---
id: 587d7b8f367417b2b2512b62
-title: Implement map on a Prototype
+title: 在原型上实现 map 方法
challengeType: 1
forumTopicId: 301230
dashedName: implement-map-on-a-prototype
@@ -8,25 +8,25 @@ dashedName: implement-map-on-a-prototype
# --description--
-As you have seen from applying `Array.prototype.map()`, or simply `map()` earlier, the `map` method returns an array of the same length as the one it was called on. It also doesn't alter the original array, as long as its callback function doesn't.
+之前用到了 `Array.prototype.map()` 方法(即 `map()`),通过 `map` 返回一个与调用它的数组长度相同的数组。 只要它的回调函数不改变原始数组,它就不会改变原始数组。
-In other words, `map` is a pure function, and its output depends solely on its inputs. Plus, it takes another function as its argument.
+换句话说,`map` 是一个纯函数,它的输出仅取决于输入的数组和作为参数传入的回调函数。 此外,它接收另一个函数作为它的参数。
-You might learn a lot about the `map` method if you implement your own version of it. It is recommended you use a `for` loop or `Array.prototype.forEach()`.
+实现一个 `map`,加深对它的了解。 你可以用 `for` 循环或者 `Array.prototype.forEach()` 方法。
# --instructions--
-Write your own `Array.prototype.myMap()`, which should behave exactly like `Array.prototype.map()`. You should not use the built-in `map` method. The `Array` instance can be accessed in the `myMap` method using `this`.
+写一个和 `Array.prototype.map()` 一样的 `Array.prototype.myMap()`。 不能使用内置的 `map` 方法。 在 `myMap` 方法内,可以使用 `this` 访问 `Array` 实例。
# --hints--
-`new_s` should equal `[46, 130, 196, 10]`.
+`new_s` 应该等于 `[46, 130, 196, 10]`。
```js
assert(JSON.stringify(new_s) === JSON.stringify([46, 130, 196, 10]));
```
-Your code should not use the `map` method.
+不能使用 `map` 方法。
```js
assert(!code.match(/\.?[\s\S]*?map/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/implement-the-filter-method-on-a-prototype.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/implement-the-filter-method-on-a-prototype.md
index a9469de977..08c03f10d0 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/implement-the-filter-method-on-a-prototype.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/implement-the-filter-method-on-a-prototype.md
@@ -1,6 +1,6 @@
---
id: 587d7b8f367417b2b2512b64
-title: Implement the filter Method on a Prototype
+title: 在原型上实现 filter 方法
challengeType: 1
forumTopicId: 301231
dashedName: implement-the-filter-method-on-a-prototype
@@ -8,21 +8,21 @@ dashedName: implement-the-filter-method-on-a-prototype
# --description--
-You might learn a lot about the `filter` method if you implement your own version of it. It is recommended you use a `for` loop or `Array.prototype.forEach()`.
+为了加深对 `filter` 的理解,可以自己实现一个。 可以用 `for` 循环或 `Array.prototype.forEach()`。
# --instructions--
-Write your own `Array.prototype.myFilter()`, which should behave exactly like `Array.prototype.filter()`. You should not use the built-in `filter` method. The `Array` instance can be accessed in the `myFilter` method using `this`.
+编写一个和 `Array.prototype.filter()` 功能一样的 `Array.prototype.myFilter()` 方法。 不能使用内置的 `filter` 方法。 在 `myFilter` 方法内部,可以使用 `this` 访问 `Array` 实例。
# --hints--
-`new_s` should equal `[23, 65, 5]`.
+`new_s` 应该等于 `[23, 65, 5]`。
```js
assert(JSON.stringify(new_s) === JSON.stringify([23, 65, 5]));
```
-Your code should not use the `filter` method.
+不应该使用 `filter` 方法。
```js
assert(!code.match(/\.?[\s\S]*?filter/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/introduction-to-currying-and-partial-application.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/introduction-to-currying-and-partial-application.md
index 1d3651620f..de39dc5653 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/introduction-to-currying-and-partial-application.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/introduction-to-currying-and-partial-application.md
@@ -1,6 +1,6 @@
---
id: 587d7dab367417b2b2512b70
-title: Introduction to Currying and Partial Application
+title: 函数柯里化
challengeType: 1
forumTopicId: 301232
dashedName: introduction-to-currying-and-partial-application
@@ -8,74 +8,72 @@ dashedName: introduction-to-currying-and-partial-application
# --description--
-The arity of a function is the number of arguments it requires. Currying a function means to convert a function of N arity into N functions of arity 1.
+arity 是函数所需的形参的数量。 函数柯里化(Currying)意思是把接受多个 arity 的函数变换成接受单一arity 的函数。
-In other words, it restructures a function so it takes one argument, then returns another function that takes the next argument, and so on.
+换句话说,就是重构函数让它接收一个参数,然后返回接收下一个参数的函数,依此类推。
-Here's an example:
+举个例子:
```js
-//Un-curried function
function unCurried(x, y) {
return x + y;
}
-//Curried function
function curried(x) {
return function(y) {
return x + y;
}
}
-//Alternative using ES6
+
const curried = x => y => x + y
-curried(1)(2) // Returns 3
+curried(1)(2)
```
-This is useful in your program if you can't supply all the arguments to a function at one time. You can save each function call into a variable, which will hold the returned function reference that takes the next argument when it's available. Here's an example using the curried function in the example above:
+`curried(1)(2)` 会返回 `3`。
+
+柯里化在不能一次为函数提供所有参数情况下很有用。 因为它可以将每个函数的调用保存到一个变量中,该变量将保存返回的函数引用,该引用在下一个参数可用时接受该参数。 下面是使用柯里化函数的例子:
```js
-// Call a curried function in parts:
var funcForY = curried(1);
-console.log(funcForY(2)); // Prints 3
+console.log(funcForY(2)); // 3
```
-Similarly, partial application can be described as applying a few arguments to a function at a time and returning another function that is applied to more arguments. Here's an example:
+类似地,局部调用( partial application)的意思是一次对一个函数应用几个参数,然后返回另一个应用更多参数的函数。 这是一个示例:
```js
-//Impartial function
function impartial(x, y, z) {
return x + y + z;
}
var partialFn = impartial.bind(this, 1, 2);
-partialFn(10); // Returns 13
+partialFn(10); // 13
```
# --instructions--
-Fill in the body of the `add` function so it uses currying to add parameters `x`, `y`, and `z`.
+填写 `add` 函数主体部分,用柯里化添加参数 `x`,`y` 和 `z`.
# --hints--
-`add(10)(20)(30)` should return `60`.
+`add(10)(20)(30)` 应返回 `60`。
```js
assert(add(10)(20)(30) === 60);
```
-`add(1)(2)(3)` should return `6`.
+`add(1)(2)(3)` 应返回 `6`。
```js
assert(add(1)(2)(3) === 6);
```
-`add(11)(22)(33)` should return `66`.
+`add(11)(22)(33)` 应返回 `66`。
```js
assert(add(11)(22)(33) === 66);
```
-Your code should include a final statement that returns `x + y + z`.
+应返回 `x + y + z` 的最终结果。
```js
assert(code.match(/[xyz]\s*?\+\s*?[xyz]\s*?\+\s*?[xyz]/g));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/learn-about-functional-programming.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/learn-about-functional-programming.md
index a0cc4d99a3..492c8e6041 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/learn-about-functional-programming.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/learn-about-functional-programming.md
@@ -1,6 +1,6 @@
---
id: 587d7b8d367417b2b2512b5b
-title: Learn About Functional Programming
+title: 学习函数式编程
challengeType: 1
forumTopicId: 301233
dashedName: learn-about-functional-programming
@@ -8,33 +8,33 @@ dashedName: learn-about-functional-programming
# --description--
-Functional programming is a style of programming where solutions are simple, isolated functions, without any side effects outside of the function scope.
+函数式编程是一种方案简单、功能独立、对作用域外没有任何副作用的编程范式。
`INPUT -> PROCESS -> OUTPUT`
-Functional programming is about:
+函数式编程:
-1) Isolated functions - there is no dependence on the state of the program, which includes global variables that are subject to change
+1)功能独立——不依赖于程序的状态(比如可能发生变化的全局变量);
-2) Pure functions - the same input always gives the same output
+2)纯函数——同一个输入永远能得到同一个输出;
-3) Functions with limited side effects - any changes, or mutations, to the state of the program outside the function are carefully controlled
+3)有限的副作用——可以严格地限制函数外部对状态的更改。
# --instructions--
-The members of freeCodeCamp happen to love tea.
+freeCodeCamp 成员在 love tea 的故事。
-In the code editor, the `prepareTea` and `getTea` functions are already defined for you. Call the `getTea` function to get 40 cups of tea for the team, and store them in the `tea4TeamFCC` variable.
+在代码编辑器中,已经为你定义好了 `prepareTea` 和 `getTea` 函数。 调用 `getTea` 函数为团队准备 40 杯茶,并将它们存储在 `tea4TeamFCC` 变量里。
# --hints--
-The `tea4TeamFCC` variable should hold 40 cups of tea for the team.
+`tea4TeamFCC` 变量里应有 40 杯为团队准备的茶。
```js
assert(tea4TeamFCC.length === 40);
```
-The `tea4TeamFCC` variable should hold cups of green tea.
+`tea4TeamFCC` 变量里应有 greenTea。
```js
assert(tea4TeamFCC[0] === 'greenTea');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/refactor-global-variables-out-of-functions.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/refactor-global-variables-out-of-functions.md
index 0eea537b77..c756cb96f2 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/refactor-global-variables-out-of-functions.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/refactor-global-variables-out-of-functions.md
@@ -1,6 +1,6 @@
---
id: 587d7b8f367417b2b2512b60
-title: Refactor Global Variables Out of Functions
+title: 在函数中重构全局变量
challengeType: 1
forumTopicId: 301235
dashedName: refactor-global-variables-out-of-functions
@@ -8,23 +8,23 @@ dashedName: refactor-global-variables-out-of-functions
# --description--
-So far, we have seen two distinct principles for functional programming:
+目前为止,我们已经看到了函数式编程的两个原则:
-1) Don't alter a variable or object - create new variables and objects and return them if need be from a function. Hint: using something like `var newArr = arrVar`, where `arrVar` is an array will simply create a reference to the existing variable and not a copy. So changing a value in `newArr` would change the value in `arrVar`.
+1) 不要更改变量或对象 - 创建新变量和对象,并在需要时从函数返回它们。 提示:使用类似 `var newArr = arrVar` 时 `arrVar` 是一个数组,代码只是创建一个对现有变量的引用,而不是副本。 所以更改 `newArr` 中的值会同时更改 `arrVar` 中的值。
-2) Declare function parameters - any computation inside a function depends only on the arguments passed to the function, and not on any global object or variable.
+2) 声明函数参数 - 函数内的任何计算仅取决于参数,而不取决于任何全局对象或变量。
-Adding one to a number is not very exciting, but we can apply these principles when working with arrays or more complex objects.
+给数字增加 1 不够刺激,我们可以在处理数组或更复杂的对象时应用这些原则。
# --instructions--
-Rewrite the code so the global array `bookList` is not changed inside either function. The `add` function should add the given `bookName` to the end of the array passed to it and return a new array (list). The `remove` function should remove the given `bookName` from the array passed to it.
+重构代码,使全局数组 `bookList` 在函数内部不会被改变。 `add` 函数可以将指定的 `bookName` 增加到数组末尾并返回一个新的数组(列表)。 `remove` 函数可以从数组中移除指定 `bookName`。
-**Note:** Both functions should return an array, and any new parameters should be added before the `bookName` parameter.
+**注意:** 两个函数都应该返回一个数组,任何新参数都应该在 `bookName` 参数之前添加。
# --hints--
-`bookList` should not change and still equal `["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]`.
+`bookList` 应等于 `["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]`.
```js
assert(
@@ -38,7 +38,7 @@ assert(
);
```
-`newBookList` should equal `["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]`.
+`newBookList` 应等于 `["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]`.
```js
assert(
@@ -53,7 +53,7 @@ assert(
);
```
-`newerBookList` should equal `["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]`.
+`newerBookList` 应等于 `["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]`.
```js
assert(
@@ -66,7 +66,7 @@ assert(
);
```
-`newestBookList` should equal `["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]`.
+`newestBookList` 应等于 `["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]`.
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/remove-elements-from-an-array-using-slice-instead-of-splice.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/remove-elements-from-an-array-using-slice-instead-of-splice.md
index 082deb8650..9da5369aee 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/remove-elements-from-an-array-using-slice-instead-of-splice.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/remove-elements-from-an-array-using-slice-instead-of-splice.md
@@ -1,6 +1,6 @@
---
id: 9d7123c8c441eeafaeb5bdef
-title: Remove Elements from an Array Using slice Instead of splice
+title: 使用 slice 而不是 splice 从数组中移除元素
challengeType: 1
forumTopicId: 301236
dashedName: remove-elements-from-an-array-using-slice-instead-of-splice
@@ -8,37 +8,38 @@ dashedName: remove-elements-from-an-array-using-slice-instead-of-splice
# --description--
-A common pattern while working with arrays is when you want to remove items and keep the rest of the array. JavaScript offers the `splice` method for this, which takes arguments for the index of where to start removing items, then the number of items to remove. If the second argument is not provided, the default is to remove items through the end. However, the `splice` method mutates the original array it is called on. Here's an example:
+使用数组时经常遇到要删除一些元素并保留数组剩余部分的情况。 为此,JavaScript 提供了 `splice` 方法,它接收两个参数:从哪里开始删除项目的索引,和要删除的项目数。 如果没有提供第二个参数,默认情况下是移除一直到结尾的所有元素。 但 `splice` 方法会改变调用它的原始数组。 举个例子:
```js
var cities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
-cities.splice(3, 1); // Returns "London" and deletes it from the cities array
-// cities is now ["Chicago", "Delhi", "Islamabad", "Berlin"]
+cities.splice(3, 1);
```
-As we saw in the last challenge, the `slice` method does not mutate the original array, but returns a new one which can be saved into a variable. Recall that the `slice` method takes two arguments for the indices to begin and end the slice (the end is non-inclusive), and returns those items in a new array. Using the `slice` method instead of `splice` helps to avoid any array-mutating side effects.
+在这里 `splice` 返回字符串 `London` 并从城市数组中删除它。 `cities` 将有值 `["Chicago", "Delhi", "Islamabad", "Berlin"]`。
+
+正如我们在上一次挑战中看到的那样,`slice` 方法不会改变原始数组,而是返回一个可以保存到变量中的新数组。 回想一下,`slice` 方法接收两个参数,从开始索引开始选取到结束(不包括该元素),并在新数组中返回这些元素。 使用 `slice` 方法替代 `splice` 有助于避免数组变化产生的副作用。
# --instructions--
-Rewrite the function `nonMutatingSplice` by using `slice` instead of `splice`. It should limit the provided `cities` array to a length of 3, and return a new array with only the first three items.
+用 `slice` 代替 `splice` 重写 `nonMutatingSplice` 函数。 将 `cities` 数组长度限制为 3,并返回一个仅包含前 3 项的新数组。
-Do not mutate the original array provided to the function.
+不要改变提供给函数的原始数组。
# --hints--
-Your code should use the `slice` method.
+你的代码中应使用 `slice` 方法。
```js
assert(code.match(/\.slice/g));
```
-Your code should not use the `splice` method.
+不能使用 `splice` 方法。
```js
assert(!code.match(/\.?[\s\S]*?splice/g));
```
-The `inputCities` array should not change.
+不能改变 `inputCities` 数组。
```js
assert(
@@ -47,7 +48,7 @@ assert(
);
```
-`nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])` should return `["Chicago", "Delhi", "Islamabad"]`.
+`nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])` 应返回 `["Chicago", "Delhi", "Islamabad"]`。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/return-part-of-an-array-using-the-slice-method.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/return-part-of-an-array-using-the-slice-method.md
index 75362aa501..bce119c079 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/return-part-of-an-array-using-the-slice-method.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/functional-programming/return-part-of-an-array-using-the-slice-method.md
@@ -1,6 +1,6 @@
---
id: 587d7b90367417b2b2512b65
-title: Return Part of an Array Using the slice Method
+title: 使用 slice 方法返回数组的一部分
challengeType: 1
forumTopicId: 301239
dashedName: return-part-of-an-array-using-the-slice-method
@@ -8,29 +8,30 @@ dashedName: return-part-of-an-array-using-the-slice-method
# --description--
-The `slice` method returns a copy of certain elements of an array. It can take two arguments, the first gives the index of where to begin the slice, the second is the index for where to end the slice (and it's non-inclusive). If the arguments are not provided, the default is to start at the beginning of the array through the end, which is an easy way to make a copy of the entire array. The `slice` method does not mutate the original array, but returns a new one.
+`slice` 方法可以从已有数组中返回指定元素。 它接受两个参数,第一个规定从何处开始选取,第二个规定从何处结束选取(不包括该元素)。 如果没有传参,则默认为从数组的开头开始到结尾结束,这是复制整个数组的简单方式。 `slice` 返回一个新数组,不会修改原始数组。
-Here's an example:
+举个例子:
```js
var arr = ["Cat", "Dog", "Tiger", "Zebra"];
var newArray = arr.slice(1, 3);
-// Sets newArray to ["Dog", "Tiger"]
```
+`newArray` 值为 `["Dog", "Tiger"]`
+
# --instructions--
-Use the `slice` method in the `sliceArray` function to return part of the `anim` array given the provided `beginSlice` and `endSlice` indices. The function should return an array.
+在 `sliceArray` 函数中使用 `slice` 方法,给出 `beginSlice` 和 `endSlice` 索引,返回 `anim` 数组的一部分。 这个函数应返回一个数组。
# --hints--
-Your code should use the `slice` method.
+应该使用 `slice` 方法。
```js
assert(code.match(/\.slice/g));
```
-The `inputAnim` variable should not change.
+不能改变 `inputAnim` 变量。
```js
assert(
@@ -39,7 +40,7 @@ assert(
);
```
-`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)` should return `["Dog", "Tiger"]`.
+`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)` 应返回 `["Dog", "Tiger"]`。
```js
assert(
@@ -48,7 +49,7 @@ assert(
);
```
-`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)` should return `["Cat"]`.
+`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)` 应返回 `["Cat"]`。
```js
assert(
@@ -57,7 +58,7 @@ assert(
);
```
-`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)` should return `["Dog", "Tiger", "Zebra"]`.
+`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)` 应返回 `["Dog", "Tiger", "Zebra"]`。
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional.md
index c3c51c294d..18d81aa004 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/arguments-optional.md
@@ -1,6 +1,6 @@
---
id: a97fd23d9b809dac9921074f
-title: Arguments Optional
+title: 可选参数
challengeType: 5
forumTopicId: 14271
dashedName: arguments-optional
@@ -8,51 +8,51 @@ dashedName: arguments-optional
# --description--
-Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum.
+创建一个将两个参数相加的函数。 如果只提供了一个参数,则返回一个需要一个参数并返回总和的函数。
-For example, `addTogether(2, 3)` should return `5`, and `addTogether(2)` should return a function.
+比如,`addTogether(2, 3)` 应该返回 `5`。 而 `addTogether(2)` 应该返回一个函数。
-Calling this returned function with a single argument will then return the sum:
+调用这个返回的函数,为它传入一个值,会返回两个值的总和:
`var sumTwoAnd = addTogether(2);`
-`sumTwoAnd(3)` returns `5`.
+`sumTwoAnd(3)` 此时应返回 `5`。
-If either argument isn't a valid number, return undefined.
+任何时候,只要任一传入的参数不是数字,就应返回 undefined。
# --hints--
-`addTogether(2, 3)` should return 5.
+`addTogether(2, 3)` 应返回 5。
```js
assert.deepEqual(addTogether(2, 3), 5);
```
-`addTogether(23, 30)` should return 53.
+`addTogether(23, 30)` 应返回 53。
```js
assert.deepEqual(addTogether(23, 30), 53);
```
-`addTogether(5)(7)` should return 12.
+`addTogether(5)(7)` 应返回 12。
```js
assert.deepEqual(addTogether(5)(7), 12);
```
-`addTogether("http://bit.ly/IqT6zt")` should return undefined.
+`addTogether("http://bit.ly/IqT6zt")` 应返回 `undefined`。
```js
assert.isUndefined(addTogether('http://bit.ly/IqT6zt'));
```
-`addTogether(2, "3")` should return undefined.
+`addTogether(2, "3")` 应返回 `undefined`。
```js
assert.isUndefined(addTogether(2, '3'));
```
-`addTogether(2)([3])` should return undefined.
+`addTogether(2)([3])` 应返回 `undefined`。
```js
assert.isUndefined(addTogether(2)([3]));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/binary-agents.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/binary-agents.md
index 954865c428..5618cdb563 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/binary-agents.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/binary-agents.md
@@ -1,6 +1,6 @@
---
id: a8d97bd4c764e91f9d2bda01
-title: Binary Agents
+title: 翻译二进制字符串
challengeType: 5
forumTopicId: 14273
dashedName: binary-agents
@@ -8,13 +8,13 @@ dashedName: binary-agents
# --description--
-Return an English translated sentence of the passed binary string.
+请实现一个函数,把传入的二进制字符串转换成英文句子。
-The binary string will be space separated.
+二进制字符串会以空格分隔。
# --hints--
-`binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111")` should return "Aren't bonfires fun!?"
+`binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111")` 应返回 `Aren't bonfires fun!?`。
```js
assert.deepEqual(
@@ -25,7 +25,7 @@ assert.deepEqual(
);
```
-`binaryAgent("01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001")` should return "I love FreeCodeCamp!"
+`binaryAgent("01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001")` 应返回 `I love FreeCodeCamp!`。
```js
assert.deepEqual(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/convert-html-entities.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/convert-html-entities.md
index 707290ef0c..314b4f31c6 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/convert-html-entities.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/convert-html-entities.md
@@ -1,6 +1,6 @@
---
id: a6b0bb188d873cb2c8729495
-title: Convert HTML Entities
+title: 转换 HTML 字符实体
challengeType: 5
forumTopicId: 16007
dashedName: convert-html-entities
@@ -8,17 +8,17 @@ dashedName: convert-html-entities
# --description--
-Convert the characters `&`, `<`, `>`, `"` (double quote), and `'` (apostrophe), in a string to their corresponding HTML entities.
+请将字符串中的 `&`、`<`、`>`、`"`(双引号)和 `'`(单引号)转换为相应的 HTML 字符实体。
# --hints--
-`convertHTML("Dolce & Gabbana")` should return `"Dolce & Gabbana"`.
+`convertHTML("Dolce & Gabbana")` 应返回 `Dolce & Gabbana`。
```js
assert.match(convertHTML('Dolce & Gabbana'), /Dolce & Gabbana/);
```
-`convertHTML("Hamburgers < Pizza < Tacos")` should return `"Hamburgers < Pizza < Tacos"`.
+`convertHTML("Hamburgers < Pizza < Tacos")` 应返回 `Hamburgers < Pizza < Tacos`。
```js
assert.match(
@@ -27,13 +27,13 @@ assert.match(
);
```
-`convertHTML("Sixty > twelve")` should return `"Sixty > twelve"`.
+`convertHTML("Sixty > twelve")` 应返回 `Sixty > twelve`。
```js
assert.match(convertHTML('Sixty > twelve'), /Sixty > twelve/);
```
-`convertHTML('Stuff in "quotation marks"')` should return `"Stuff in "quotation marks""`.
+`convertHTML('Stuff in "quotation marks"')` 应返回 `Stuff in "quotation marks"`。
```js
assert.match(
@@ -42,19 +42,19 @@ assert.match(
);
```
-`convertHTML("Schindler's List")` should return `"Schindler's List"`.
+`convertHTML("Schindler's List")` 应返回 `Schindler's List`。
```js
assert.match(convertHTML("Schindler's List"), /Schindler's List/);
```
-`convertHTML("<>")` should return `"<>"`.
+`convertHTML("<>")` 应返回 `<>`。
```js
assert.match(convertHTML('<>'), /<>/);
```
-`convertHTML("abc")` should return `"abc"`.
+`convertHTML("abc")` 应该返回字符串 `abc`。
```js
assert.strictEqual(convertHTML('abc'), 'abc');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays.md
index 228d55cf80..7e437f8c06 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays.md
@@ -1,6 +1,6 @@
---
id: a5de63ebea8dbee56860f4f2
-title: Diff Two Arrays
+title: 数组的对称差
challengeType: 5
forumTopicId: 16008
dashedName: diff-two-arrays
@@ -8,20 +8,19 @@ dashedName: diff-two-arrays
# --description--
-Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other words, return the symmetric difference of the two arrays.
+比较两个数组并返回一个新数组,包含所有只在其中一个数组中出现的元素,排除两个数组都存在的元素。 换言之,我们需要返回两个数组的对称差。
-**Note**
-You can return the array with its elements in any order.
+**注意:**返回数组中的元素顺序不会影响挑战的测试结果。
# --hints--
-`diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])` should return an array.
+`diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])` 应返回一个数组。
```js
assert(typeof diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]) === 'object');
```
-`["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]` should return `["pink wool"]`.
+`["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]` 应返回 `["pink wool"]`。
```js
assert.sameMembers(
@@ -33,7 +32,7 @@ assert.sameMembers(
);
```
-`["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]` should return an array with one item.
+`["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]` 应返回一个长度为 1 的数组。
```js
assert(
@@ -44,7 +43,7 @@ assert(
);
```
-`["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]` should return `["diorite", "pink wool"]`.
+`["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]` 应返回 `["diorite", "pink wool"]`。
```js
assert.sameMembers(
@@ -56,7 +55,7 @@ assert.sameMembers(
);
```
-`["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]` should return an array with two items.
+`["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]` 应返回一个长度为 2 的数组。
```js
assert(
@@ -67,7 +66,7 @@ assert(
);
```
-`["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"]` should return `[]`.
+`["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"]` 应返回 `[]`。
```js
assert.sameMembers(
@@ -79,7 +78,7 @@ assert.sameMembers(
);
```
-`["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"]` should return an empty array.
+`["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"]` 应返回一个空数组。
```js
assert(
@@ -90,19 +89,19 @@ assert(
);
```
-`[1, 2, 3, 5], [1, 2, 3, 4, 5]` should return `[4]`.
+`[1, 2, 3, 5], [1, 2, 3, 4, 5]` 应返回 `[4]`。
```js
assert.sameMembers(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]), [4]);
```
-`[1, 2, 3, 5], [1, 2, 3, 4, 5]` should return an array with one item.
+`[1, 2, 3, 5], [1, 2, 3, 4, 5]` 应返回一个长度为 1 的数组。
```js
assert(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]).length === 1);
```
-`[1, "calf", 3, "piglet"], [1, "calf", 3, 4]` should return `["piglet", 4]`.
+`[1, "calf", 3, "piglet"], [1, "calf", 3, 4]` 应返回 `["piglet", 4]`。
```js
assert.sameMembers(diffArray([1, 'calf', 3, 'piglet'], [1, 'calf', 3, 4]), [
@@ -111,13 +110,13 @@ assert.sameMembers(diffArray([1, 'calf', 3, 'piglet'], [1, 'calf', 3, 4]), [
]);
```
-`[1, "calf", 3, "piglet"], [1, "calf", 3, 4]` should return an array with two items.
+`[1, "calf", 3, "piglet"], [1, "calf", 3, 4]` 应返回一个长度为 2 的数组。
```js
assert(diffArray([1, 'calf', 3, 'piglet'], [1, 'calf', 3, 4]).length === 2);
```
-`[], ["snuffleupagus", "cookie monster", "elmo"]` should return `["snuffleupagus", "cookie monster", "elmo"]`.
+`[], ["snuffleupagus", "cookie monster", "elmo"]` 应返回 `["snuffleupagus", "cookie monster", "elmo"]`。
```js
assert.sameMembers(diffArray([], ['snuffleupagus', 'cookie monster', 'elmo']), [
@@ -127,13 +126,13 @@ assert.sameMembers(diffArray([], ['snuffleupagus', 'cookie monster', 'elmo']), [
]);
```
-`[], ["snuffleupagus", "cookie monster", "elmo"]` should return an array with three items.
+`[], ["snuffleupagus", "cookie monster", "elmo"]` 应返回一个长度为 3 的数组。
```js
assert(diffArray([], ['snuffleupagus', 'cookie monster', 'elmo']).length === 3);
```
-`[1, "calf", 3, "piglet"], [7, "filly"]` should return `[1, "calf", 3, "piglet", 7, "filly"]`.
+`[1, "calf", 3, "piglet"], [7, "filly"]` 应返回 `[1, "calf", 3, "piglet", 7, "filly"]`。
```js
assert.sameMembers(diffArray([1, 'calf', 3, 'piglet'], [7, 'filly']), [
@@ -146,7 +145,7 @@ assert.sameMembers(diffArray([1, 'calf', 3, 'piglet'], [7, 'filly']), [
]);
```
-`[1, "calf", 3, "piglet"], [7, "filly"]` should return an array with six items.
+`[1, "calf", 3, "piglet"], [7, "filly"]` 应返回一个长度为 6 的数组。
```js
assert(diffArray([1, 'calf', 3, 'piglet'], [7, 'filly']).length === 6);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/dna-pairing.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/dna-pairing.md
index d9f36cd281..6b26aa7ca1 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/dna-pairing.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/dna-pairing.md
@@ -1,6 +1,6 @@
---
id: afd15382cdfb22c9efe8b7de
-title: DNA Pairing
+title: DNA 配对
challengeType: 5
forumTopicId: 16009
dashedName: dna-pairing
@@ -8,19 +8,19 @@ dashedName: dna-pairing
# --description--
-The DNA strand is missing the pairing element. Take each character, get its pair, and return the results as a 2d array.
+给出的 DNA 链上缺少配对元素。 请基于每个字符,获取与其配对的元素,并将结果作为二维数组返回。
-[Base pairs](http://en.wikipedia.org/wiki/Base_pair) are a pair of AT and CG. Match the missing element to the provided character.
+DNA 的[碱基对](http://en.wikipedia.org/wiki/Base_pair) 有两种形式:一种是 A 与 T,一种是 C 与 G。 请为参数中给出的每个字符配对相应的碱基。
-Return the provided character as the first element in each array.
+注意,参数中给出的字符应作为每个子数组中的第一个元素返回。
-For example, for the input GCG, return \[\["G", "C"], \["C","G"],\["G", "C"]]
+例如,传入 `GCG` 时,应返回 `[["G", "C"], ["C","G"], ["G", "C"]]`。
-The character and its pair are paired up in an array, and all the arrays are grouped into one encapsulating array.
+字符和它的配对组成一个数组中,所有配对数组放在一个数组里。
# --hints--
-`pairElement("ATCGA")` should return `[["A","T"],["T","A"],["C","G"],["G","C"],["A","T"]]`.
+`pairElement("ATCGA")` 应返回 `[["A","T"],["T","A"],["C","G"],["G","C"],["A","T"]]`。
```js
assert.deepEqual(pairElement('ATCGA'), [
@@ -32,7 +32,7 @@ assert.deepEqual(pairElement('ATCGA'), [
]);
```
-`pairElement("TTGAG")` should return `[["T","A"],["T","A"],["G","C"],["A","T"],["G","C"]]`.
+`pairElement("TTGAG")` 应返回 `[["T","A"],["T","A"],["G","C"],["A","T"],["G","C"]]`。
```js
assert.deepEqual(pairElement('TTGAG'), [
@@ -44,7 +44,7 @@ assert.deepEqual(pairElement('TTGAG'), [
]);
```
-`pairElement("CTCTA")` should return `[["C","G"],["T","A"],["C","G"],["T","A"],["A","T"]]`.
+`pairElement("CTCTA")` 应返回 `[["C","G"],["T","A"],["C","G"],["T","A"],["A","T"]]`。
```js
assert.deepEqual(pairElement('CTCTA'), [
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/drop-it.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/drop-it.md
index b2d97fca2f..e2ec44b826 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/drop-it.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/drop-it.md
@@ -1,6 +1,6 @@
---
id: a5deed1811a43193f9f1c841
-title: Drop it
+title: 根据参数删除数组元素
challengeType: 5
forumTopicId: 16010
dashedName: drop-it
@@ -8,13 +8,13 @@ dashedName: drop-it
# --description--
-Given the array `arr`, iterate through and remove each element starting from the first element (the 0 index) until the function `func` returns `true` when the iterated element is passed through it.
+给定数组 `arr`,从数组的第一个元素开始,用函数 `func` 来检查数组的每个元素是否返回 `true`。 如果返回 false,就把这个元素删除。 持续执行删除操作,直到某个元素传入 func 时返回 true 为止。
-Then return the rest of the array once the condition is satisfied, otherwise, `arr` should be returned as an empty array.
+然后在条件满足后返回数组的其余部分,否则, `arr` 应作为空数组返回。
# --hints--
-`dropElements([1, 2, 3, 4], function(n) {return n >= 3;})` should return `[3, 4]`.
+`dropElements([1, 2, 3, 4], function(n) {return n >= 3;})` 应返回 `[3, 4]`。
```js
assert.deepEqual(
@@ -25,7 +25,7 @@ assert.deepEqual(
);
```
-`dropElements([0, 1, 0, 1], function(n) {return n === 1;})` should return `[1, 0, 1]`.
+`dropElements([0, 1, 0, 1], function(n) {return n === 1;})` 应返回 `[1, 0, 1]`。
```js
assert.deepEqual(
@@ -36,7 +36,7 @@ assert.deepEqual(
);
```
-`dropElements([1, 2, 3], function(n) {return n > 0;})` should return `[1, 2, 3]`.
+`dropElements([1, 2, 3], function(n) {return n > 0;})` 应返回 `[1, 2, 3]`。
```js
assert.deepEqual(
@@ -47,7 +47,7 @@ assert.deepEqual(
);
```
-`dropElements([1, 2, 3, 4], function(n) {return n > 5;})` should return `[]`.
+`dropElements([1, 2, 3, 4], function(n) {return n > 5;})` 应返回 `[]`。
```js
assert.deepEqual(
@@ -58,7 +58,7 @@ assert.deepEqual(
);
```
-`dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})` should return `[7, 4]`.
+`dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})` 应返回 `[7, 4]`。
```js
assert.deepEqual(
@@ -69,7 +69,7 @@ assert.deepEqual(
);
```
-`dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})` should return `[3, 9, 2]`.
+`dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})` 应返回 `[3, 9, 2]`。
```js
assert.deepEqual(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/everything-be-true.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/everything-be-true.md
index 7a93f8ae2a..92df453bd5 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/everything-be-true.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/everything-be-true.md
@@ -1,6 +1,6 @@
---
id: a10d2431ad0c6a099a4b8b52
-title: Everything Be True
+title: 一切都是True
challengeType: 5
forumTopicId: 16011
dashedName: everything-be-true
@@ -8,17 +8,17 @@ dashedName: everything-be-true
# --description--
-Check if the predicate (second argument) is truthy on all elements of a collection (first argument).
+检查谓词(第二个参数)在集合(第一个参数)的所有元素是否为 truthy。
-In other words, you are given an array collection of objects. The predicate `pre` will be an object property and you need to return `true` if its value is `truthy`. Otherwise, return `false`.
+换句话说,你将获得一个对象的数组集合。 如果数组中的每个对象里,`pre` 对应属性值均为 `truthy`,则返回 `true`。 否则,返回 `false` 。
-In JavaScript, `truthy` values are values that translate to `true` when evaluated in a Boolean context.
+JavaScript 中,如果一个值在 Boolean 的上下文中的执行结果为 `true`,那么我们称这个值是 `truthy` 的。
-Remember, you can access object properties through either dot notation or `[]` notation.
+别忘了,你可以使用点号表示法或方括号表示法(`[]`)来访问对象的属性。
# --hints--
-`truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex")` should return true.
+`truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex")` 应返回 `true`。
```js
assert.strictEqual(
@@ -35,7 +35,7 @@ assert.strictEqual(
);
```
-`truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex")` should return false.
+`truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex")` 应返回 `false`。
```js
assert.strictEqual(
@@ -52,7 +52,7 @@ assert.strictEqual(
);
```
-`truthCheck([{"user": "Tinky-Winky", "sex": "male", "age": 0}, {"user": "Dipsy", "sex": "male", "age": 3}, {"user": "Laa-Laa", "sex": "female", "age": 5}, {"user": "Po", "sex": "female", "age": 4}], "age")` should return false.
+`truthCheck([{"user": "Tinky-Winky", "sex": "male", "age": 0}, {"user": "Dipsy", "sex": "male", "age": 3}, {"user": "Laa-Laa", "sex": "female", "age": 5}, {"user": "Po", "sex": "female", "age": 4}], "age")` 应返回 `false`。
```js
assert.strictEqual(
@@ -69,7 +69,7 @@ assert.strictEqual(
);
```
-`truthCheck([{"name": "Pete", "onBoat": true}, {"name": "Repeat", "onBoat": true}, {"name": "FastForward", "onBoat": null}], "onBoat")` should return false
+`truthCheck([{"name": "Pete", "onBoat": true}, {"name": "Repeat", "onBoat": true}, {"name": "FastForward", "onBoat": null}], "onBoat")` 应返回 `false`。
```js
assert.strictEqual(
@@ -85,7 +85,7 @@ assert.strictEqual(
);
```
-`truthCheck([{"name": "Pete", "onBoat": true}, {"name": "Repeat", "onBoat": true, "alias": "Repete"}, {"name": "FastForward", "onBoat": true}], "onBoat")` should return true
+`truthCheck([{"name": "Pete", "onBoat": true}, {"name": "Repeat", "onBoat": true, "alias": "Repete"}, {"name": "FastForward", "onBoat": true}], "onBoat")` 应返回 `true`。
```js
assert.strictEqual(
@@ -101,13 +101,13 @@ assert.strictEqual(
);
```
-`truthCheck([{"single": "yes"}], "single")` should return true
+`truthCheck([{"single": "yes"}], "single")` 应返回 `true`。
```js
assert.strictEqual(truthCheck([{ single: 'yes' }], 'single'), true);
```
-`truthCheck([{"single": ""}, {"single": "double"}], "single")` should return false
+`truthCheck([{"single": ""}, {"single": "double"}], "single")` 应返回 `false`。
```js
assert.strictEqual(
@@ -116,7 +116,7 @@ assert.strictEqual(
);
```
-`truthCheck([{"single": "double"}, {"single": undefined}], "single")` should return false
+`truthCheck([{"single": "double"}, {"single": undefined}], "single")` 应返回 `false`。
```js
assert.strictEqual(
@@ -125,7 +125,7 @@ assert.strictEqual(
);
```
-`truthCheck([{"single": "double"}, {"single": NaN}], "single")` should return false
+`truthCheck([{"single": "double"}, {"single": NaN}], "single")` 应返回 `false`。
```js
assert.strictEqual(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person.md
index b9458749e7..da2d5022c3 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person.md
@@ -1,6 +1,6 @@
---
id: a2f1d72d9b908d0bd72bb9f6
-title: Make a Person
+title: 构建 Person 类
challengeType: 5
forumTopicId: 16020
dashedName: make-a-person
@@ -8,7 +8,7 @@ dashedName: make-a-person
# --description--
-Fill in the object constructor with the following methods below:
+用以下方法填充对象构造函数:
```js
getFirstName()
@@ -19,53 +19,53 @@ setLastName(last)
setFullName(firstAndLast)
```
-Run the tests to see the expected output for each method. The methods that take an argument must accept only one argument and it has to be a string. These methods must be the only available means of interacting with the object.
+运行测试以查看每个方法的预期输出。 方法接收一个参数,因此必须要有一个参数,并且其类型应该为字符串。 这些方法必须是与对象交互的唯一可用方法。
# --hints--
-`Object.keys(bob).length` should return 6.
+`Object.keys(bob).length` 应返回 6。
```js
assert.deepEqual(Object.keys(bob).length, 6);
```
-`bob instanceof Person` should return true.
+`bob instanceof Person` 应返回 `true`。
```js
assert.deepEqual(bob instanceof Person, true);
```
-`bob.firstName` should return undefined.
+`bob.firstName` 应该返回 `undefined`。
```js
assert.deepEqual(bob.firstName, undefined);
```
-`bob.lastName` should return undefined.
+`bob.lastName` 应该返回 `undefined`。
```js
assert.deepEqual(bob.lastName, undefined);
```
-`bob.getFirstName()` should return "Bob".
+`bob.getFirstName()` 应该返回字符串 `Bob`.
```js
assert.deepEqual(bob.getFirstName(), 'Bob');
```
-`bob.getLastName()` should return "Ross".
+`bob.getLastName()` 应该返回字符串 `Ross`.
```js
assert.deepEqual(bob.getLastName(), 'Ross');
```
-`bob.getFullName()` should return "Bob Ross".
+`bob.getFullName()` 应该返回字符串 `Bob Ross`.
```js
assert.deepEqual(bob.getFullName(), 'Bob Ross');
```
-`bob.getFullName()` should return "Haskell Ross" after `bob.setFirstName("Haskell")`.
+`bob.getFullName()` 应该在 `bob.setFirstName("Haskell")` 之后返回字符串 `Haskell Ross`。
```js
assert.strictEqual(
@@ -77,7 +77,7 @@ assert.strictEqual(
);
```
-`bob.getFullName()` should return "Haskell Curry" after `bob.setLastName("Curry")`.
+`bob.getFullName()` 应该在 `bob.setLastName("Curry")` 之后返回字符串 `Haskell Curry`。
```js
assert.strictEqual(
@@ -90,7 +90,7 @@ assert.strictEqual(
);
```
-`bob.getFullName()` should return "Haskell Curry" after `bob.setFullName("Haskell Curry")`.
+`bob.getFullName()` 应该返回字符串 `Haskell Curry` 之后的 `bob.setFullName("Haskell Curry")`。
```js
assert.strictEqual(
@@ -102,7 +102,7 @@ assert.strictEqual(
);
```
-`bob.getFirstName()` should return "Haskell" after `bob.setFullName("Haskell Curry")`.
+`bob.getFirstName()` 应该返回字符串 `Haskell` 之后的 `bob.setFullName("Haskell Curry")`。
```js
assert.strictEqual(
@@ -114,7 +114,7 @@ assert.strictEqual(
);
```
-`bob.getLastName()` should return "Curry" after `bob.setFullName("Haskell Curry")`.
+`bob.getLastName()` 应该返回字符串 `Curry` 之后 `bob.setFullName("Haskell Curry")`。
```js
assert.strictEqual(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris.md
index 74118356a4..472c9388ee 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris.md
@@ -1,6 +1,6 @@
---
id: af4afb223120f7348cdfc9fd
-title: Map the Debris
+title: 计算轨道周期
challengeType: 5
forumTopicId: 16021
dashedName: map-the-debris
@@ -8,19 +8,19 @@ dashedName: map-the-debris
# --description--
-Return a new array that transforms the elements' average altitude into their orbital periods (in seconds).
+在这道题目中,我们需要写一个计算天体轨道周期(单位是秒)的函数。
-The array will contain objects in the format `{name: 'name', avgAlt: avgAlt}`.
+它接收一个对象数组参数 arr,对象中包含表示天体名称的 name 属性,及表示天体表面平均海拔的 avgAlt 属性。 就像这样:`{name: 'name', avgAlt: avgAlt}`。
-You can read about orbital periods [on Wikipedia](http://en.wikipedia.org/wiki/Orbital_period).
+你可以在这条[维基百科](http://en.wikipedia.org/wiki/Orbital_period)的链接中找到轨道周期的计算公式:
-The values should be rounded to the nearest whole number. The body being orbited is Earth.
+最终的计算结果应取整到最接近的整数。 在这里计算地球的轨道周期。
-The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418 km3s-2.
+地球半径为 6367.4447 公里,地球的 GM 值为 398600.4418 km 3 s -2 。
# --hints--
-`orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}])` should return `[{name: "sputnik", orbitalPeriod: 86400}]`.
+`orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}])` 应返回 `[{name: "sputnik", orbitalPeriod: 86400}]` 。
```js
assert.deepEqual(orbitalPeriod([{ name: 'sputnik', avgAlt: 35873.5553 }]), [
@@ -28,7 +28,7 @@ assert.deepEqual(orbitalPeriod([{ name: 'sputnik', avgAlt: 35873.5553 }]), [
]);
```
-`orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])` should return `[{name : "iss", orbitalPeriod: 5557}, {name: "hubble", orbitalPeriod: 5734}, {name: "moon", orbitalPeriod: 2377399}]`.
+`orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])` 应返回 `[{name : "iss", orbitalPeriod: 5557}, {name: "hubble", orbitalPeriod: 5734}, {name: "moon", orbitalPeriod: 2377399}]`。
```js
assert.deepEqual(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters.md
index c5e807a7a4..e13495714f 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters.md
@@ -1,6 +1,6 @@
---
id: af7588ade1100bde429baf20
-title: Missing letters
+title: 寻找缺失的字母
challengeType: 5
forumTopicId: 16023
dashedName: missing-letters
@@ -8,37 +8,37 @@ dashedName: missing-letters
# --description--
-Find the missing letter in the passed letter range and return it.
+在这道题目中,我们需要写一个函数,找出传入的字符串里缺失的字母并返回它。
-If all letters are present in the range, return undefined.
+如果所有字母都在传入的字符串范围内,返回 `undefined`。
# --hints--
-`fearNotLetter("abce")` should return "d".
+`fearNotLetter("abce")` 应该返回字符串 `d`。
```js
assert.deepEqual(fearNotLetter('abce'), 'd');
```
-`fearNotLetter("abcdefghjklmno")` should return "i".
+`fearNotLetter("abcdefghjklmno")` 应返回 `i`。
```js
assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i');
```
-`fearNotLetter("stvwx")` should return "u".
+`fearNotLetter("stvwx")` 应该返回字符串 `u`。
```js
assert.deepEqual(fearNotLetter('stvwx'), 'u');
```
-`fearNotLetter("bcdf")` should return "e".
+`fearNotLetter("bcdf")` 应该返回字符串 `e`。
```js
assert.deepEqual(fearNotLetter('bcdf'), 'e');
```
-`fearNotLetter("abcdefghijklmnopqrstuvwxyz")` should return undefined.
+`fearNotLetter("abcdefghijklmnopqrstuvwxyz")` 应返回 `undefined`。
```js
assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin.md
index af40b695bf..aa29127839 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin.md
@@ -1,6 +1,6 @@
---
id: aa7697ea2477d1316795783b
-title: Pig Latin
+title: 儿童黑话
challengeType: 5
forumTopicId: 16039
dashedName: pig-latin
@@ -8,55 +8,55 @@ dashedName: pig-latin
# --description--
-Pig Latin is a way of altering English Words. The rules are as follows:
+儿童黑话也叫 Pig Latin,是一种英语语言游戏。 规则如下:
-\- If a word begins with a consonant, take the first consonant or consonant cluster, move it to the end of the word, and add "ay" to it.
+\- 如果单词以辅音开头,就把第一个辅音字母或第一组辅音簇移到单词的结尾,并在后面加上 `ay`。
-\- If a word begins with a vowel, just add "way" at the end.
+\- 如果单词以元音开头,只需要在结尾加上 `way`。
# --instructions--
-Translate the provided string to Pig Latin. Input strings are guaranteed to be English words in all lowercase.
+请把传入的字符串根据上述规则翻译成儿童黑话并返回结果。 输入的字符串一定是一个小写的英文单词。
# --hints--
-`translatePigLatin("california")` should return "aliforniacay".
+`translatePigLatin("california")` 应该返回字符串 `aliforniacay`。
```js
assert.deepEqual(translatePigLatin('california'), 'aliforniacay');
```
-`translatePigLatin("paragraphs")` should return "aragraphspay".
+`translatePigLatin("paragraphs")` 应该返回字符串 `aragraphspay`。
```js
assert.deepEqual(translatePigLatin('paragraphs'), 'aragraphspay');
```
-`translatePigLatin("glove")` should return "oveglay".
+`translatePigLatin("glove")` 应该返回字符串 `oveglay`。
```js
assert.deepEqual(translatePigLatin('glove'), 'oveglay');
```
-`translatePigLatin("algorithm")` should return "algorithmway".
+`translatePigLatin("algorithm")` 应该返回字符串 `algorithmway`。
```js
assert.deepEqual(translatePigLatin('algorithm'), 'algorithmway');
```
-`translatePigLatin("eight")` should return "eightway".
+`translatePigLatin("eight")` 应该返回字符串 `eightway`。
```js
assert.deepEqual(translatePigLatin('eight'), 'eightway');
```
-Should handle words where the first vowel comes in the middle of the word. `translatePigLatin("schwartz")` should return "artzschway".
+应该处理单词的第一个元音在单词中间的位置的情况。 `translatePigLatin("schwartz")` 应该返回字符串 `artzschway`。
```js
assert.deepEqual(translatePigLatin('schwartz'), 'artzschway');
```
-Should handle words without vowels. `translatePigLatin("rhythm")` should return "rhythmay".
+应该处理不带元音的单词。 `translatePigLatin("rhythm")` 应该返回字符串 `rhythmay`。
```js
assert.deepEqual(translatePigLatin('rhythm'), 'rhythmay');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/search-and-replace.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/search-and-replace.md
index f4ca7362bd..0a9868bf4a 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/search-and-replace.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/search-and-replace.md
@@ -1,6 +1,6 @@
---
id: a0b5010f579e69b815e7c5d6
-title: Search and Replace
+title: 搜索与替换
challengeType: 5
forumTopicId: 16045
dashedName: search-and-replace
@@ -8,20 +8,19 @@ dashedName: search-and-replace
# --description--
-Perform a search and replace on the sentence using the arguments provided and return the new sentence.
+在这道题目中,我们需要写一个字符串的搜索与替换函数,它的返回值为完成替换后的新字符串。
-First argument is the sentence to perform the search and replace on.
+这个函数接收的第一个参数为待替换的句子。
-Second argument is the word that you will be replacing (before).
+第二个参数为句中需要被替换的单词。
-Third argument is what you will be replacing the second argument with (after).
+第三个参数为替换后的单词。
-**Note**
-Preserve the case of the first character in the original word when you are replacing it. For example if you mean to replace the word "Book" with the word "dog", it should be replaced as "Dog"
+**注意:** 在更换原始单词时保留原始单词中第一个字符的大小写。 即如果传入的第二个参数为 `Book`,第三个参数为 `dog`,那么替换后的结果应为 `Dog`
# --hints--
-`myReplace("Let us go to the store", "store", "mall")` should return "Let us go to the mall".
+`myReplace("Let us go to the store", "store", "mall")` 应返回 `Let us go to the mall`。
```js
assert.deepEqual(
@@ -30,7 +29,7 @@ assert.deepEqual(
);
```
-`myReplace("He is Sleeping on the couch", "Sleeping", "sitting")` should return "He is Sitting on the couch".
+`myReplace("He is Sleeping on the couch", "Sleeping", "sitting")` 应返回 `He is Sitting on the couch`。
```js
assert.deepEqual(
@@ -39,7 +38,7 @@ assert.deepEqual(
);
```
-`myReplace("I think we should look up there", "up", "Down")` should return "I think we should look down there".
+`myReplace("I think we should look up there", "up", "Down")` 应返回 `I think we should look down there`。
```js
assert.deepEqual(
@@ -48,7 +47,7 @@ assert.deepEqual(
);
```
-`myReplace("This has a spellngi error", "spellngi", "spelling")` should return "This has a spelling error".
+`myReplace("This has a spellngi error", "spellngi", "spelling")` 应返回 `This has a spelling error`。
```js
assert.deepEqual(
@@ -57,7 +56,7 @@ assert.deepEqual(
);
```
-`myReplace("His name is Tom", "Tom", "john")` should return "His name is John".
+`myReplace("His name is Tom", "Tom", "john")` 应返回 `His name is John`。
```js
assert.deepEqual(
@@ -66,7 +65,7 @@ assert.deepEqual(
);
```
-`myReplace("Let us get back to more Coding", "Coding", "algorithms")` should return "Let us get back to more Algorithms".
+`myReplace("Let us get back to more Coding", "Coding", "algorithms")` 应返回 `Let us get back to more Algorithms`。
```js
assert.deepEqual(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy.md
index 5fbf7d5aa8..2d61e2d41f 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy.md
@@ -1,6 +1,6 @@
---
id: a39963a4c10bc8b4d4f06d7e
-title: Seek and Destroy
+title: 过滤数组元素
challengeType: 5
forumTopicId: 16046
dashedName: seek-and-destroy
@@ -8,38 +8,37 @@ dashedName: seek-and-destroy
# --description--
-You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.
+你将获得一个初始数组(`destroyer` 函数中的第一个参数),后跟一个或多个参数。 从初始数组中移除所有与后续参数相等的元素。
-**Note**
-You have to use the `arguments` object.
+**注意:** 你可以使用 `arguments` 对象。
# --hints--
-`destroyer([1, 2, 3, 1, 2, 3], 2, 3)` should return `[1, 1]`.
+`destroyer([1, 2, 3, 1, 2, 3], 2, 3)` 应返回 `[1, 1]`。
```js
assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1]);
```
-`destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)` should return `[1, 5, 1]`.
+`destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)` 应返回 `[1, 5, 1]`。
```js
assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1]);
```
-`destroyer([3, 5, 1, 2, 2], 2, 3, 5)` should return `[1]`.
+`destroyer([3, 5, 1, 2, 2], 2, 3, 5)` 应返回 `[1]`。
```js
assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1]);
```
-`destroyer([2, 3, 2, 3], 2, 3)` should return `[]`.
+`destroyer([2, 3, 2, 3], 2, 3)` 应返回 `[]`。
```js
assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), []);
```
-`destroyer(["tree", "hamburger", 53], "tree", 53)` should return `["hamburger"]`.
+`destroyer(["tree", "hamburger", 53], "tree", 53)` 应返回 `["hamburger"]`。
```js
assert.deepEqual(destroyer(['tree', 'hamburger', 53], 'tree', 53), [
@@ -47,7 +46,7 @@ assert.deepEqual(destroyer(['tree', 'hamburger', 53], 'tree', 53), [
]);
```
-`destroyer(["possum", "trollo", 12, "safari", "hotdog", 92, 65, "grandma", "bugati", "trojan", "yacht"], "yacht", "possum", "trollo", "safari", "hotdog", "grandma", "bugati", "trojan")` should return `[12,92,65]`.
+`destroyer(["possum", "trollo", 12, "safari", "hotdog", 92, 65, "grandma", "bugati", "trojan", "yacht"], "yacht", "possum", "trollo", "safari", "hotdog", "grandma", "bugati", "trojan")` 应返回 `[12,92,65]`。
```js
assert.deepEqual(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple.md
index e6c39f5ee6..2c8092ea41 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple.md
@@ -1,6 +1,6 @@
---
id: ae9defd7acaf69703ab432ea
-title: Smallest Common Multiple
+title: 找出数字范围内的最小公倍数
challengeType: 5
forumTopicId: 16075
dashedName: smallest-common-multiple
@@ -8,45 +8,45 @@ dashedName: smallest-common-multiple
# --description--
-Find the smallest common multiple of the provided parameters that can be evenly divided by both, as well as by all sequential numbers in the range between these parameters.
+找到给定参数的最小公倍数,可以被这两个参数整除,也可以被指定范围内的所以整数整除。
-The range will be an array of two numbers that will not necessarily be in numerical order.
+注意,较小数不一定总是出现在数组的第一个元素。
-For example, if given 1 and 3, find the smallest common multiple of both 1 and 3 that is also evenly divisible by all numbers *between* 1 and 3. The answer here would be 6.
+例如,如果给定 1 和 3,找到 1 和 3 的最小公倍数,也可以被 1 到 3 *之间*的所有数字整除。 这里的答案将是 6。
# --hints--
-`smallestCommons([1, 5])` should return a number.
+`smallestCommons([1, 5])` 应返回 a number。
```js
assert.deepEqual(typeof smallestCommons([1, 5]), 'number');
```
-`smallestCommons([1, 5])` should return 60.
+`smallestCommons([1, 5])` 应返回 60。
```js
assert.deepEqual(smallestCommons([1, 5]), 60);
```
-`smallestCommons([5, 1])` should return 60.
+`smallestCommons([5, 1])` 应返回 60。
```js
assert.deepEqual(smallestCommons([5, 1]), 60);
```
-`smallestCommons([2, 10])` should return 2520.
+`smallestCommons([2, 10])` 应返回 2520。
```js
assert.deepEqual(smallestCommons([2, 10]), 2520);
```
-`smallestCommons([1, 13])` should return 360360.
+`smallestCommons([1, 13])` 应返回 360360。
```js
assert.deepEqual(smallestCommons([1, 13]), 360360);
```
-`smallestCommons([23, 18])` should return 6056820.
+`smallestCommons([23, 18])` 应返回 6056820。
```js
assert.deepEqual(smallestCommons([23, 18]), 6056820);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sorted-union.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sorted-union.md
index cbc9cd794a..d625992eea 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sorted-union.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sorted-union.md
@@ -1,6 +1,6 @@
---
id: a105e963526e7de52b219be9
-title: Sorted Union
+title: 集合排序
challengeType: 5
forumTopicId: 16077
dashedName: sorted-union
@@ -8,29 +8,29 @@ dashedName: sorted-union
# --description--
-Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.
+编写一个带有两个或更多数组的函数,并按原始提供的数组的顺序返回一个新的唯一值数组。
-In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.
+换句话说,所有数组中出现的所有值都应按其原始顺序包括在内,但最终数组中不得重复。
-The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.
+去重后的数字应按其出现在参数中的原始顺序排序,最终数组不应按数字大小进行排序。
-Check the assertion tests for examples.
+如有疑问,请先浏览下方的测试用例。
# --hints--
-`uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1])` should return `[1, 3, 2, 5, 4]`.
+`uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1])` 应返回 `[1, 3, 2, 5, 4]`。
```js
assert.deepEqual(uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4]);
```
-`uniteUnique([1, 2, 3], [5, 2, 1])` should return `[1, 2, 3, 5]`.
+`uniteUnique([1, 2, 3], [5, 2, 1])` 应返回 `[1, 2, 3, 5]`。
```js
assert.deepEqual(uniteUnique([1, 2, 3], [5, 2, 1]), [1, 2, 3, 5]);
```
-`uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])` should return `[1, 2, 3, 5, 4, 6, 7, 8]`.
+`uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])` 应返回 `[1, 2, 3, 5, 4, 6, 7, 8]`。
```js
assert.deepEqual(uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]), [
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/spinal-tap-case.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/spinal-tap-case.md
index c68938ce89..993154a39c 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/spinal-tap-case.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/spinal-tap-case.md
@@ -1,6 +1,6 @@
---
id: a103376db3ba46b2d50db289
-title: Spinal Tap Case
+title: 短线连接格式
challengeType: 5
forumTopicId: 16078
dashedName: spinal-tap-case
@@ -8,23 +8,23 @@ dashedName: spinal-tap-case
# --description--
-Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.
+将字符串转换为短线连接格式。 短线连接格式是小写单词全部小写并以破折号分隔。
# --hints--
-`spinalCase("This Is Spinal Tap")` should return `"this-is-spinal-tap"`.
+`spinalCase("This Is Spinal Tap")` 应返回 `this-is-spinal-tap`。
```js
assert.deepEqual(spinalCase('This Is Spinal Tap'), 'this-is-spinal-tap');
```
-`spinalCase("thisIsSpinalTap")` should return `"this-is-spinal-tap"`.
+`spinalCase("thisIsSpinalTap")` 应返回 `this-is-spinal-tap`。
```js
assert.strictEqual(spinalCase('thisIsSpinalTap'), 'this-is-spinal-tap');
```
-`spinalCase("The_Andy_Griffith_Show")` should return `"the-andy-griffith-show"`.
+`spinalCase("The_Andy_Griffith_Show")` 应返回 `the-andy-griffith-show`。
```js
assert.strictEqual(
@@ -33,7 +33,7 @@ assert.strictEqual(
);
```
-`spinalCase("Teletubbies say Eh-oh")` should return `"teletubbies-say-eh-oh"`.
+`spinalCase("Teletubbies say Eh-oh")` 应返回 `teletubbies-say-eh-oh`。
```js
assert.strictEqual(
@@ -42,7 +42,7 @@ assert.strictEqual(
);
```
-`spinalCase("AllThe-small Things")` should return `"all-the-small-things"`.
+`spinalCase("AllThe-small Things")` 应返回 `all-the-small-things`。
```js
assert.strictEqual(spinalCase('AllThe-small Things'), 'all-the-small-things');
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md
index 5744ab7e20..434e0d47af 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/steamroller.md
@@ -1,6 +1,6 @@
---
id: ab306dbdcc907c7ddfc30830
-title: Steamroller
+title: 数组扁平化
challengeType: 5
forumTopicId: 16079
dashedName: steamroller
@@ -8,35 +8,35 @@ dashedName: steamroller
# --description--
-Flatten a nested array. You must account for varying levels of nesting.
+嵌套数组扁平化成一维数组。 必须考虑到各种深度的嵌套层级。
# --hints--
-`steamrollArray([[["a"]], [["b"]]])` should return `["a", "b"]`.
+`steamrollArray([[["a"]], [["b"]]])` 应返回 `["a", "b"]`。
```js
assert.deepEqual(steamrollArray([[['a']], [['b']]]), ['a', 'b']);
```
-`steamrollArray([1, [2], [3, [[4]]]])` should return `[1, 2, 3, 4]`.
+`steamrollArray([1, [2], [3, [[4]]]])` 应返回 `[1, 2, 3, 4]`。
```js
assert.deepEqual(steamrollArray([1, [2], [3, [[4]]]]), [1, 2, 3, 4]);
```
-`steamrollArray([1, [], [3, [[4]]]])` should return `[1, 3, 4]`.
+`steamrollArray([1, [], [3, [[4]]]])` 应返回 `[1, 3, 4]`。
```js
assert.deepEqual(steamrollArray([1, [], [3, [[4]]]]), [1, 3, 4]);
```
-`steamrollArray([1, {}, [3, [[4]]]])` should return `[1, {}, 3, 4]`.
+`steamrollArray([1, {}, [3, [[4]]]])` 应返回 `[1, {}, 3, 4]`。
```js
assert.deepEqual(steamrollArray([1, {}, [3, [[4]]]]), [1, {}, 3, 4]);
```
-Your solution should not use the `Array.prototype.flat()` or `Array.prototype.flatMap()` methods.
+代码中不应使用 `Array.prototype.flat()` 或 `Array.prototype.flatMap()` 方法。
```js
assert(!code.match(/\.\s*flat\s*\(/) && !code.match(/\.\s*flatMap\s*\(/));
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-numbers-in-a-range.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-numbers-in-a-range.md
index a7dbdaeecc..28df6db9c7 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-numbers-in-a-range.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-numbers-in-a-range.md
@@ -1,6 +1,6 @@
---
id: a3566b1109230028080c9345
-title: Sum All Numbers in a Range
+title: 范围内的数字求和
challengeType: 5
forumTopicId: 16083
dashedName: sum-all-numbers-in-a-range
@@ -8,37 +8,37 @@ dashedName: sum-all-numbers-in-a-range
# --description--
-We'll pass you an array of two numbers. Return the sum of those two numbers plus the sum of all the numbers between them. The lowest number will not always come first.
+我们会传入一个由两个数字组成的数组。 给出一个含有两个数字的数组,我们需要写一个函数,让它返回这两个数字间所有数字(包含这两个数字)的总和。 最低的数字并不总是第一位。
-For example, `sumAll([4,1])` should return `10` because sum of all the numbers between 1 and 4 (both inclusive) is `10`.
+例如,`sumAll([4,1])` 应返回 `10`,因为从 1 到 4(包含 1、4)的所有数字的和是 `10`。
# --hints--
-`sumAll([1, 4])` should return a number.
+`sumAll([1, 4])` 应返回一个数字。
```js
assert(typeof sumAll([1, 4]) === 'number');
```
-`sumAll([1, 4])` should return 10.
+`sumAll([1, 4])` 应返回 10。
```js
assert.deepEqual(sumAll([1, 4]), 10);
```
-`sumAll([4, 1])` should return 10.
+`sumAll([4, 1])` 应返回 10。
```js
assert.deepEqual(sumAll([4, 1]), 10);
```
-`sumAll([5, 10])` should return 45.
+`sumAll([5, 10])` 应返回 45。
```js
assert.deepEqual(sumAll([5, 10]), 45);
```
-`sumAll([10, 5])` should return 45.
+`sumAll([10, 5])` 应返回 45。
```js
assert.deepEqual(sumAll([10, 5]), 45);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-odd-fibonacci-numbers.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-odd-fibonacci-numbers.md
index 0c5b625e71..8d4de6a544 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-odd-fibonacci-numbers.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-odd-fibonacci-numbers.md
@@ -1,6 +1,6 @@
---
id: a5229172f011153519423690
-title: Sum All Odd Fibonacci Numbers
+title: 求斐波那契数列中的奇数之和
challengeType: 5
forumTopicId: 16084
dashedName: sum-all-odd-fibonacci-numbers
@@ -8,45 +8,45 @@ dashedName: sum-all-odd-fibonacci-numbers
# --description--
-Given a positive integer `num`, return the sum of all odd Fibonacci numbers that are less than or equal to `num`.
+在这道题目中,我们需要写一个函数,参数为一个正整数 `num`,返回值为斐波那契数列中,小于或等于 `num` 的奇数之和。
-The first two numbers in the Fibonacci sequence are 1 and 1. Every additional number in the sequence is the sum of the two previous numbers. The first six numbers of the Fibonacci sequence are 1, 1, 2, 3, 5 and 8.
+斐波那契数列中,第一和第二个数字都是 1。 后面的每个数字由之前两数相加得出。 斐波那契数列的前六个数字分别为:1、1、2、3、5、8。
-For example, `sumFibs(10)` should return `10` because all odd Fibonacci numbers less than or equal to `10` are 1, 1, 3, and 5.
+比如,`sumFibs(10)` 应该返回 `10`。 因为斐波那契数列中,比 `10` 小的数字只有 1、1、3、5。
# --hints--
-`sumFibs(1)` should return a number.
+`sumFibs(1)` 应返回一个数字。
```js
assert(typeof sumFibs(1) === 'number');
```
-`sumFibs(1000)` should return 1785.
+`sumFibs(1000)` 应返回 1785。
```js
assert(sumFibs(1000) === 1785);
```
-`sumFibs(4000000)` should return 4613732.
+`sumFibs(4000000)` 应返回 4613732。
```js
assert(sumFibs(4000000) === 4613732);
```
-`sumFibs(4)` should return 5.
+`sumFibs(4)` 应返回 5。
```js
assert(sumFibs(4) === 5);
```
-`sumFibs(75024)` should return 60696.
+`sumFibs(75024)` 应返回 60696。
```js
assert(sumFibs(75024) === 60696);
```
-`sumFibs(75025)` should return 135721.
+`sumFibs(75025)` 应返回 135721。
```js
assert(sumFibs(75025) === 135721);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-primes.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-primes.md
index 57295dd11e..c0c21e9d65 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-primes.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-primes.md
@@ -1,6 +1,6 @@
---
id: a3bfc1673c0526e06d3ac698
-title: Sum All Primes
+title: 质数求和
challengeType: 5
forumTopicId: 16085
dashedName: sum-all-primes
@@ -8,25 +8,25 @@ dashedName: sum-all-primes
# --description--
-A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself. For example, 2 is a prime number because it is only divisible by 1 and 2. In contrast, 4 is not prime since it is divisible by 1, 2 and 4.
+质数(prime number)是大于 1 且仅可以被 1 和自己整除的数。 比如,2 就是一个质数,因为它只可以被 1 和 2(它本身)整除。 相反,4 不是质数,因为它可以被 1, 2 和 4 整除。
-Rewrite `sumPrimes` so it returns the sum of all prime numbers that are less than or equal to num.
+请完成 `sumPrimes` 方法,使其返回小于等于传入参数数字的所有质数之和。
# --hints--
-`sumPrimes(10)` should return a number.
+`sumPrimes(10)` 应返回一个数字。
```js
assert.deepEqual(typeof sumPrimes(10), 'number');
```
-`sumPrimes(10)` should return 17.
+`sumPrimes(10)` 应返回 17。
```js
assert.deepEqual(sumPrimes(10), 17);
```
-`sumPrimes(977)` should return 73156.
+`sumPrimes(977)` 应返回 73156。
```js
assert.deepEqual(sumPrimes(977), 73156);
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou.md
index b0a565be94..f972afdc1e 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou.md
@@ -1,6 +1,6 @@
---
id: a8e512fbe388ac2f9198f0fa
-title: Wherefore art thou
+title: 找出包含特定键值对的对象
challengeType: 5
forumTopicId: 16092
dashedName: wherefore-art-thou
@@ -8,13 +8,13 @@ dashedName: wherefore-art-thou
# --description--
-Make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching name and value pairs (second argument). Each name and value pair of the source object has to be present in the object from the collection if it is to be included in the returned array.
+创建一个查看对象数组(第一个参数)的函数,并返回具有匹配的名称和值对的所有对象的数组(第二个参数)。 如果要包含在返回的数组中,则源对象的每个名称和值对都必须存在于集合中的对象中。
-For example, if the first argument is `[{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }]`, and the second argument is `{ last: "Capulet" }`, then you must return the third object from the array (the first argument), because it contains the name and its value, that was passed on as the second argument.
+比如,如果第一个参数是 `[{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }]`,第二个参数是 `{ last: "Capulet" }`。
# --hints--
-`whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" })` should return `[{ first: "Tybalt", last: "Capulet" }]`.
+`whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" })` 应返回 `[{ first: "Tybalt", last: "Capulet" }]`。
```js
assert.deepEqual(
@@ -30,7 +30,7 @@ assert.deepEqual(
);
```
-`whatIsInAName([{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }], { "apple": 1 })` should return `[{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }]`.
+`whatIsInAName([{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }], { "apple": 1 })` 应返回 `[{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }]`。
```js
assert.deepEqual(
@@ -41,7 +41,7 @@ assert.deepEqual(
);
```
-`whatIsInAName([{ "apple": 1, "bat": 2 }, { "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "bat": 2 })` should return `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }]`.
+`whatIsInAName([{ "apple": 1, "bat": 2 }, { "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "bat": 2 })` 应返回 `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }]`。
```js
assert.deepEqual(
@@ -56,7 +56,7 @@ assert.deepEqual(
);
```
-`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "cookie": 2 })` should return `[{ "apple": 1, "bat": 2, "cookie": 2 }]`.
+`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "cookie": 2 })` 应返回 `[{ "apple": 1, "bat": 2, "cookie": 2 }]`。
```js
assert.deepEqual(
@@ -68,7 +68,7 @@ assert.deepEqual(
);
```
-`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }, { "bat":2 }], { "apple": 1, "bat": 2 })` should return `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie":2 }]`.
+`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }, { "bat":2 }], { "apple": 1, "bat": 2 })` 应返回 `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie":2 }]`。
```js
assert.deepEqual(
@@ -88,7 +88,7 @@ assert.deepEqual(
);
```
-`whatIsInAName([{"a": 1, "b": 2, "c": 3}], {"a": 1, "b": 9999, "c": 3})` should return `[]`
+`whatIsInAName([{"a": 1, "b": 2, "c": 3}], {"a": 1, "b": 9999, "c": 3})` 应返回 `[]`。
```js
assert.deepEqual(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/caesars-cipher.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/caesars-cipher.md
index 7e0a8c9f36..2b7edcaa94 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/caesars-cipher.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/caesars-cipher.md
@@ -1,6 +1,6 @@
---
id: 56533eb9ac21ba0edf2244e2
-title: Caesars Cipher
+title: 凯撒密码
challengeType: 5
forumTopicId: 16003
dashedName: caesars-cipher
@@ -8,35 +8,35 @@ dashedName: caesars-cipher
# --description--
-One of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher. In a shift cipher the meanings of the letters are shifted by some set amount.
+凯撒密码( Caesar cipher)是最简单且最广为人知的密码(ciphers),也被称为移位密码(shift cipher)。 在移位密码中,明文中的字母通过按照一个固定数目进行偏移后被替换成新的字母。
-A common modern use is the [ROT13](https://en.wikipedia.org/wiki/ROT13) cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.
+[ROT13](https://en.wikipedia.org/wiki/ROT13) 是一个被广泛使用的加密技术,明文中的所有字母都被移动 13 位。 也就是, `A ↔ N`,`B ↔ O` 等等。
-Write a function which takes a [ROT13](https://en.wikipedia.org/wiki/ROT13) encoded string as input and returns a decoded string.
+编写一个函数,它将 [ROT13](https://en.wikipedia.org/wiki/ROT13) 编码的字符串作为输入并返回解码字符串。
-All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.
+所有解码后的字母都必须为字母大写。 请不要解码非字母的字符(例如,空格、标点符号),但你需要在结果中保留它们。
# --hints--
-`rot13("SERR PBQR PNZC")` should decode to `FREE CODE CAMP`
+`rot13("SERR PBQR PNZC")` 应解码为 `FREE CODE CAMP`
```js
assert(rot13('SERR PBQR PNZC') === 'FREE CODE CAMP');
```
-`rot13("SERR CVMMN!")` should decode to `FREE PIZZA!`
+`rot13("SERR CVMMN!")` 应解码为 `FREE PIZZA!`
```js
assert(rot13('SERR CVMMN!') === 'FREE PIZZA!');
```
-`rot13("SERR YBIR?")` should decode to `FREE LOVE?`
+`rot13("SERR YBIR?")` 应解码为 `FREE LOVE?`
```js
assert(rot13('SERR YBIR?') === 'FREE LOVE?');
```
-`rot13("GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.")` should decode to `THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.`
+`rot13("GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.")` 应解码为 `THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.`
```js
assert(
diff --git a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register.md b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register.md
index 49336bf373..f89918bebd 100644
--- a/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register.md
+++ b/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register.md
@@ -1,6 +1,6 @@
---
id: aa2e6f85cab2ab736c9a9b24
-title: Cash Register
+title: 计算找零
challengeType: 5
forumTopicId: 16012
dashedName: cash-register
@@ -8,21 +8,21 @@ dashedName: cash-register
# --description--
-Design a cash register drawer function `checkCashRegister()` that accepts purchase price as the first argument (`price`), payment as the second argument (`cash`), and cash-in-drawer (`cid`) as the third argument.
+请编写一个用于收银机的函数 `checkCashRegister()`:它的第一个参数为售价 `price`、第二个参数为支付金额 `cash`、第三个参数为收银机內的金额 `cid`。
-`cid` is a 2D array listing available currency.
+`cid` 是包含货币面值的二维数组。
-The `checkCashRegister()` function should always return an object with a `status` key and a `change` key.
+函数 `checkCashRegister()` 应返回含有 `status` 属性和 `change` 属性的对象。
-Return `{status: "INSUFFICIENT_FUNDS", change: []}` if cash-in-drawer is less than the change due, or if you cannot return the exact change.
+如果收银机內的金额少于应找回的零钱数,或者你无法返回确切的数目时,返回 `{status: "INSUFFICIENT_FUNDS", change: []}`。
-Return `{status: "CLOSED", change: [...]}` with cash-in-drawer as the value for the key `change` if it is equal to the change due.
+如果收银机內的金额恰好等于应找回的零钱数,返回 `{status: "CLOSED", change: [...]}`,其中 `change` 的属性值就是收银机內的金额。
-Otherwise, return `{status: "OPEN", change: [...]}`, with the change due in coins and bills, sorted in highest to lowest order, as the value of the `change` key.
+否则,返回 `{status: "OPEN", change: [...]}`,其中 `change` 键值是应找回的零钱数,并将找零的面值由高到低排序。
-