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

1.5.10#160

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
otmon76 merged 2 commits intojavascript-tutorial:masterfromotmon76:1.5.10
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@

```js run
letuser = {
name: "John",
years: 30
letuživatel = {
jméno: "Jan",
roky: 30
};

let {name, years: age, isAdmin = false} =user;
let {jméno, roky: věk, jeSprávce = false} =uživatel;

alert(name ); //John
alert(age ); // 30
alert(isAdmin ); // false
alert(jméno ); //Jan
alert(věk ); // 30
alert(jeSprávce ); // false
```
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,32 +2,32 @@ importance: 5

---

#Destructuring assignment
#Destrukturační přiřazení

We have an object:
Máme objekt:

```js
letuser = {
name: "John",
years: 30
letuživatel = {
jméno: "Jan",
roky: 30
};
```

Write the destructuring assignment that reads:
Napište destrukturační přiřazení, které načte:

-`name` property into the variable `name`.
-`years` property into the variable `age`.
-`isAdmin` property into the variable `isAdmin` (false,if no such property)
-vlastnost `jméno` do proměnné `jméno`.
-vlastnost `roky` do proměnné `věk`.
-vlastnost `jeSprávce` do proměnné `jeSprávce` (false,pokud taková vlastnost není).

Here's an example of the values after your assignment:
Zde je příklad hodnot po vašem přiřazení:

```js
letuser = {name: "John",years: 30 };
letuživatel = {jméno: "Jan",roky: 30 };

//your code to the left side:
// ... =user
//váš kód na levé straně:
// ... =uživatel

alert(name ); //John
alert(age ); // 30
alert(isAdmin ); // false
alert(jméno ); //Jan
alert(věk ); // 30
alert(jeSprávce ); // false
```
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
functiontopSalary(salaries) {
functionnejvyššíPlat(platy) {

letmaxSalary = 0;
letmaxName = null;
letmaxPlat = 0;
letmaxJméno = null;

for(const [name, salary] of Object.entries(salaries)) {
if (maxSalary <salary) {
maxSalary =salary;
maxName =name;
for(const [jméno, plat] of Object.entries(platy)) {
if (maxPlat <plat) {
maxPlat =plat;
maxJméno =jméno;
}
}

returnmaxName;
returnmaxJméno;
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
describe("topSalary", function() {
it("returns top-paid person", function() {
letsalaries = {
"John": 100,
"Pete": 300,
"Mary": 250
describe("nejvyššíPlat", function() {
it("vrátí nejlépe placenou osobu", function() {
letplaty = {
"Jan": 100,
"Petr": 300,
"Marie": 250
};

assert.equal(topSalary(salaries), "Pete" );
assert.equal(nejvyššíPlat(platy), "Petr" );
});

it("returns null for the empty object", function() {
assert.isNull(topSalary({}) );
it("pro prázdný objekt vrátí null", function() {
assert.isNull(nejvyššíPlat({}) );
});
});
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,21 +2,21 @@ importance: 5

---

#The maximal salary
#Nejvyšší plat

There is a `salaries` object:
Máme objekt `platy`:

```js
letsalaries = {
"John": 100,
"Pete": 300,
"Mary": 250
letplaty = {
"Jan": 100,
"Petr": 300,
"Marie": 250
};
```

Create the function `topSalary(salaries)` that returns the name of the top-paid person.
Vytvořte funkci `nejvyššíPlat(platy)`, která vrátí jméno nejlépe placené osoby.

-If `salaries` is empty, it should return `null`.
-If there are multiple top-paid persons, return any of them.
-Je-li objekt `platy` prázdný, měla by vrátit `null`.
-Jestliže je nejlépe placených osob více, může vrátit libovolnou z nich.

P.S.Use`Object.entries`and destructuring to iterate over key/value pairs.
P.S.K iteraci nad dvojicemi klíč/hodnota použijte`Object.entries`a destrukturaci.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp