work
This commit is contained in:
parent
1bffa43db4
commit
057783d216
373 changed files with 203 additions and 190 deletions
17
1-js/3-object-basics/1-object/3-sum-object/solution.md
Normal file
17
1-js/3-object-basics/1-object/3-sum-object/solution.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
|
||||
```js run
|
||||
let salaries = {
|
||||
John: 100,
|
||||
Ann: 160,
|
||||
Pete: 130
|
||||
}
|
||||
|
||||
let sum = 0;
|
||||
for(let key in salaries) {
|
||||
sum += salaries[key];
|
||||
}
|
||||
|
||||
alert(sum); // 390
|
||||
```
|
||||
|
19
1-js/3-object-basics/1-object/3-sum-object/task.md
Normal file
19
1-js/3-object-basics/1-object/3-sum-object/task.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
importance: 5
|
||||
|
||||
---
|
||||
|
||||
# Sum object properties
|
||||
|
||||
We have an object storing salaries of our team:
|
||||
|
||||
```js
|
||||
let salaries = {
|
||||
John: 100,
|
||||
Ann: 160,
|
||||
Pete: 130
|
||||
}
|
||||
```
|
||||
|
||||
Write the code to sum all salaries and store in the variable `sum`. Should be `390` in the example above.
|
||||
|
||||
Use `for..in` loop to iterate over the object.
|
Loading…
Add table
Add a link
Reference in a new issue