add solution with fixed indentation
This commit is contained in:
parent
38e1bb5c52
commit
a5425e7d8a
1 changed files with 14 additions and 0 deletions
|
@ -0,0 +1,14 @@
|
|||
```js run
|
||||
function sumSalaries(salaries) {
|
||||
|
||||
let sum = 0;
|
||||
for (let salary of Object.values(salaries)) {
|
||||
sum += salary;
|
||||
}
|
||||
|
||||
return sum; // 650
|
||||
}
|
||||
```
|
||||
Or, optionally, we could also get the sum using `Object.values` and `reduce`:
|
||||
|
||||
`Object.values(salaries).reduce((a, b) => a + b) // 650`
|
Loading…
Add table
Add a link
Reference in a new issue