Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 5

---

# Destructuring assignment
# Atribuição de desestruturação

We have an object:
Temos um objeto:

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"que leia: a propriedade name para a variável name" ficou um pouco literal ("reads X into Y"). Algo como "extraia" soa mais natural:

Suggested change
Escreva a atribuição via desestruturação que extraia:

Write the destructuring assignment that reads:
Escreva a atribuição de desestruturação que extraia:

- `name` property into the variable `name`.
- `years` property into the variable `age`.
- `isAdmin` property into the variable `isAdmin` (false, if no such property)
- A propriedade `name` para a variável `name`.
- A propriedade `years` para a variável `age`.
- A propriedade `isAdmin` para a variável `isAdmin` (false, se essa propriedade não existir)

Here's an example of the values after your assignment:
Aqui está um exemplo dos valores depois da sua atribuição:

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

// your code to the left side:
// seu código do lado esquerdo:
// ... = 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
# O maior salário

There is a `salaries` object:
Existe um objeto `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.
Crie a função `topSalary(salaries)` que retorna o nome da pessoa com o maior salário.

- If `salaries` is empty, it should return `null`.
- If there are multiple top-paid persons, return any of them.
- Se `salaries` estiver vazio, deve retornar `null`.
- Se houver mais de uma pessoa com o maior salário, pode retornar qualquer uma delas.

P.S. Use `Object.entries` and destructuring to iterate over key/value pairs.
P.S. Use `Object.entries` e desestruturação para percorrer os pares chave/valor.
Loading