Skip to content
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

Translating 1-js/05-data-types/09-destructuring-assignment #82

Merged
merged 5 commits into from
May 27, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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` 和解构语法来遍历键/值对。