Skip to content

Destructuring assignment #200

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
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
@@ -1,4 +1,3 @@

```js run
let user = {
name: "John",
Expand All @@ -10,4 +9,4 @@ let {name, years: age, isAdmin = false} = user;
alert( name ); // John
alert( age ); // 30
alert( isAdmin ); // false
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 5

---

# Destructuring assignment
# Zuweisung mit Destrukturierung

We have an object:
Wir haben ein Objekt:

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

Write the destructuring assignment that reads:
Schreibe die Zuweisung mit Destrukturierung, die folgendes liest:

- `name` property into the variable `name`.
- `years` property into the variable `age`.
- `isAdmin` property into the variable `isAdmin` (false, if no such property)
- `name` Eigenschaft in die Variable `name`.
- `years` Eigenschaft in die Variable `age`.
- `isAdmin` Eigenschaft in die Variable `isAdmin` (false, falls keine solche Eigenschaft existiert)

Here's an example of the values after your assignment:
Hier ist ein Beispiel von den Werten nach deiner Zuweisung:

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

// your code to the left side:
// dein Code auf der linken Seite:
// ... = 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
# Das maximale Gehalt

There is a `salaries` object:
Es gibt ein `salaries` Objekt:

```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.
Erstelle die Funktion `topSalary(salaries)`, die den Namen der Person mit dem höchsten Gehalt zurückgibt.

- If `salaries` is empty, it should return `null`.
- If there are multiple top-paid persons, return any of them.
- Wenn `salaries` leer ist, sollte es `null` zurückgeben.
- Wenn es mehrere Personen mit dem höchsten Gehalt gibt, gib eine beliebige davon zurück.

P.S. Use `Object.entries` and destructuring to iterate over key/value pairs.
P.S. Verwende `Object.entries` und Destructuring, um über Schlüssel-Wert-Paare zu iterieren.
Loading