Skip to content
Merged
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@

```js run
let user = {
name: "John",
name: "Іван",
years: 30
};

let {name, years: age, isAdmin = false} = user;

alert( name ); // John
alert( name ); // Іван
alert( age ); // 30
alert( isAdmin ); // false
```
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,32 +2,32 @@ importance: 5

---

# Destructuring assignment
# Деструктуроване присвоєння

We have an object:
У нас є об’єкт:

```js
let user = {
name: "John",
name: "Іван",
years: 30
};
```

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 no such property)
- властивість `name` у змінну `name`.
- властивість `years` у змінну `age`.
- властивість `isAdmin` у змінну `isAdmin` (false, якщо така властивість відсутня)

Here's an example of the values after your assignment:
Ось приклад значень після вашого присвоєння:

```js
let user = { name: "John", years: 30 };
let user = { name: "Іван", years: 30 };

// your code to the left side:
// ваш код зліва:
// ... = user

alert( name ); // John
alert( name ); // Іван
alert( age ); // 30
alert( isAdmin ); // false
```
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,21 +2,21 @@ importance: 5

---

# The maximal salary
# Максимальна зарплата

There is a `salaries` object:
Є об’єкт `salaries`:

```js
let salaries = {
Comment thread
hordiienko-tatiana marked this conversation as resolved.
"John": 100,
"Pete": 300,
"Mary": 250
"Іван": 100,
"Петро": 300,
"Марія": 250
};
```

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.
P.S. Використовуйте `Object.entries` і деструктурування для перебору пар ключ/значення.
Loading