Skip to content

Commit

Permalink
Translating 1-js/05-data-types/09-destructuring-assignment (#82)
Browse files Browse the repository at this point in the history
* Translating 1-js/05-data-types/09-destructuring-assignment

* Polishing

* Polishing

* Update task.md

* Update article.md
  • Loading branch information
kezhenxu94 authored and leviding committed May 27, 2018
1 parent 5bbe28e commit 6f1cbb8
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 5

---

# Destructuring assignment
# 解构赋值

We have an object:
有以下对象:

```js
let user = {
Expand All @@ -13,18 +13,18 @@ let user = {
};
```

Write the destructuring assignment that reads:
写一个解构赋值语句使得:

- `name` property into the variable `name`.
- `years` property into the variable `age`.
- `isAdmin` property into the variable `isAdmin` (false if absent)
- `name` 属性赋值给变量 `name`
- `years` 属性赋值给 `age`
- `isAdmin` 属性赋值给变量 `isAdmin`(如果属性缺失则赋值为 false)。

The values after the assignment should be:
赋值语句后的值必须是:

```js
let user = { name: "John", years: 30 };

// your code to the left side:
// 等号左侧是你的代码
// ... = user

alert( name ); // John
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 5

---

# The maximal salary
# 最高薪资

There is a `salaries` object:
以下是一个 `salaries` 对象:

```js
let salaries = {
Expand All @@ -14,9 +14,9 @@ let salaries = {
};
```

Create the function `topSalary(salaries)` that returns the name of the top-paid person.
新建一个函数 `topSalary(salaries)`,返回拥有最高薪资的人。

- If `salaries` is empty, it should return `null`.
- If there are multiple top-paid persons, return any of them.
- 如果 `salaries` 是空的,函数应该返回 `null`
- 如果有多个最高薪资的人,返回其中任意一个。

P.S. Use `Object.entries` and destructuring to iterate over key/value pairs.
提示:使用 `Object.entries` 和解构语法来遍历键/值对。

0 comments on commit 6f1cbb8

Please sign in to comment.