Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Destructuring assignment#222

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
10 commits
Select commitHold shift + click to select a range
9a53256
Destructuring assignment
hordiienko-tatianaNov 21, 2021
148af75
Merge branch 'master' into 01-05-10-destructuring-assignment
hordiienko-tatianaNov 21, 2021
0d62da3
Update 1-js/05-data-types/10-destructuring-assignment/1-destruct-user…
tarasyyykNov 22, 2021
a4c5b0c
Update 1-js/05-data-types/10-destructuring-assignment/1-destruct-user…
tarasyyykNov 22, 2021
da40e7e
Merge branch 'javascript-tutorial:master' into 01-05-10-destructuring…
hordiienko-tatianaNov 27, 2021
f1b715d
Update 1-js/05-data-types/10-destructuring-assignment/1-destruct-user…
hordiienko-tatianaNov 27, 2021
0256c50
Apply suggestions from code review
hordiienko-tatianaNov 27, 2021
e3a18d4
Apply changes from code review - 2
hordiienko-tatianaNov 27, 2021
a1bd9c7
Apply code review changes - 3
hordiienko-tatianaNov 27, 2021
5dff09d
Apply suggestions from code review
tarasyyykNov 28, 2021
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
View file
Open in desktop
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
```
View file
Open in desktop
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
```
View file
Open in desktop
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 = {
"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

[8]ページ先頭

©2009-2025 Movatter.jp