Skip to content

tiny translation update #587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 1-js/05-data-types/03-string/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,16 +525,16 @@ alert( str );

字符通过数字代码进行比较。越大的代码意味着字符越大。`a`(97)的代码大于 `Z`(90)。

- 所有小写字母都是大写字母,因为它们的代码更大。
- 一些想 `Ö` 的字母与主要字母表不同。这里的代码比从 `a` 到 `z` 的代码都要大。
- 所有小写字母追随在大写字母之后,因为它们的代码更大。
- 一些像 `Ö` 的字母与主要字母表不同。这里,它的代码比任何从 `a` 到 `z` 的代码都要大。

### 正确的比较

执行字符串比较的“正确”算法比看起来更复杂,因为不同语言的字母都不相同。

因此浏览器需要知道要比较的语言。

幸运地是,所有现代浏览器(IE-10 都需要额外的库 [Intl.JS](https://github.com/andyearnshaw/Intl.js/)) 支持国际化标准 [ECMA 402](http://www.ecma-international.org/ecma-402/1.0/ECMA-402.pdf)。
幸运地是,所有现代浏览器(IE10- 需要额外的库 [Intl.JS](https://github.com/andyearnshaw/Intl.js/)) 支持国际化标准 [ECMA 402](http://www.ecma-international.org/ecma-402/1.0/ECMA-402.pdf)。

它提供了一种特殊的方法来比较不同语言的字符串,遵循它们的规则。

Expand Down
2 changes: 1 addition & 1 deletion 1-js/05-data-types/05-array-methods/1-camelcase/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ importance: 5

写函数 `camelize(str)` 将诸如 "my-short-string" 之类的由短划线分隔的单词变成骆驼式的 "myShortString"。

即:删除所有短横线,短横线后的第一个单词变为大写
即:删除所有短横线,短横线后的每一个单词变为首字母大写

例如:

Expand Down
17 changes: 9 additions & 8 deletions 1-js/05-data-types/05-array-methods/12-reduce-object/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ importance: 4

---

# Create keyed object from array
# 从数组创建键(值)对象

Let's say we received an array of users in the form `{id:..., name:..., age... }`.
假设我们有以下形式的用户数组 `{id:..., name:..., age... }`

Create a function `groupById(arr)` that creates an object from it, with `id` as the key, and array items as values.
创建一个函数 `groupById(arr)` 从该数组创建对象,以 `id` 为键(key),数组项为值。

For example:
例如:

```js
let users = [
Expand All @@ -20,7 +20,7 @@ let users = [
let usersById = groupById(users);

/*
// after the call we have:
// 调用方法后我们得到:

usersById = {
john: {id: 'john', name: "John Smith", age: 20}
Expand All @@ -30,8 +30,9 @@ usersById = {
*/
```

Such function is really handy when working with server data.

In this task we assume that `id` is unique. There may be no two array items with the same `id`.
处理服务端数据时,此功能很有用。

Please use array `.reduce` method in the solution.
在这个任务里我们假设 `id` 是唯一的。没有哪两个数组项具有相同的 `id` 。

请使用数组 `.reduce` 方法解决。
2 changes: 1 addition & 1 deletion 1-js/05-data-types/05-array-methods/9-shuffle/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ JavaScript 引擎的代码结果可能会有所不同,但我们已经可以看
```js
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1)); // r 从 0 到 i 的随机索引
let j = Math.floor(Math.random() * (i + 1)); // 从 0 到 i 的随机索引
[array[i], array[j]] = [array[j], array[i]]; // 交换元素
}
}
Expand Down
4 changes: 2 additions & 2 deletions 1-js/05-data-types/05-array-methods/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ alert(youngerUsers.length); // 2
- 查询元素:
- `indexOf/lastIndexOf(item, pos)` — 从 `pos` 找到 `item`,则返回索引否则返回 `-1`。
- `includes(value)` — 如果数组有 `value`,则返回 `true`,否则返回 `false`。
- `find/filter(func)` — 通过函数过滤元素,返回 `true` 条件的符合 find 函数的第一个值或符合 filter 函数的全部值
- `find/filter(func)` — 通过函数过滤元素,返回符合 `true` 条件的第一个值/所有值
- `findIndex` 和 `find` 类似,但返回索引而不是值。

- 转换数组:
Expand All @@ -718,7 +718,7 @@ alert(youngerUsers.length); // 2

- [arr.fill(value, start, end)](mdn:js/Array/fill) — 从 `start` 到 `end` 用 `value` 重复填充数组。

- [arr.copyWithin(target, start, end)](mdn:js/Array/copyWithin) — copies its elements from position `start` till position `end` into *itself*, at position `target` (overwrites existing).将其元素从 `start` 到 `end` 在 `target` 位置复制到 **本身**(覆盖现有)。
- [arr.copyWithin(target, start, end)](mdn:js/Array/copyWithin) — 将从 `start`(开始)位置到 `end`(结束)位置 [译注:不包含结束位元素] 的所有元素复制到 *自身* 的 `target`(目标)位置中(覆盖现有元素)。

有关完整列表,请参阅[手册](mdn:js/Array)。

Expand Down