We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 38e1bb5 commit a5425e7Copy full SHA for a5425e7
1-js/05-data-types/08-keys-values-entries/01-sum-salaries/solution.md
@@ -0,0 +1,14 @@
1
+```js run
2
+function sumSalaries(salaries) {
3
+
4
+ let sum = 0;
5
+ for (let salary of Object.values(salaries)) {
6
+ sum += salary;
7
+ }
8
9
+ return sum; // 650
10
+}
11
+```
12
+Or, optionally, we could also get the sum using `Object.values` and `reduce`:
13
14
+`Object.values(salaries).reduce((a, b) => a + b) // 650`
0 commit comments