add solution with fixed indentation

This commit is contained in:
11un 2019-01-29 13:22:00 -08:00
parent 38e1bb5c52
commit a5425e7d8a

View file

@ -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`