Skip to content

Destructuring assignment #155

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

Merged
merged 17 commits into from
Sep 17, 2021
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
# مقداردهی تجزیه‌کننده‌ی ساختار

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 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 };

// 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` و تجزیه ساختار برای حلقه زدن در جفت‌های کلید/مقدار استفاده کنید.
Loading