edited alice's wage difference, wage is based on the average of her male counterparts and rounded up for easy comprehension.

This commit is contained in:
Kelly K H 2020-02-18 13:14:35 -05:00
parent 9acc1302a1
commit 642b56329e

View file

@ -302,7 +302,7 @@ let company = {
salary: 1000 salary: 1000
}, { }, {
name: 'Alice', name: 'Alice',
salary: 600 salary: 1600
}], }],
development: { development: {
@ -350,7 +350,7 @@ The algorithm is probably even easier to read from the code:
```js run ```js run
let company = { // the same object, compressed for brevity let company = { // the same object, compressed for brevity
sales: [{name: 'John', salary: 1000}, {name: 'Alice', salary: 600 }], sales: [{name: 'John', salary: 1000}, {name: 'Alice', salary: 1600 }],
development: { development: {
sites: [{name: 'Peter', salary: 2000}, {name: 'Alex', salary: 1800 }], sites: [{name: 'Peter', salary: 2000}, {name: 'Alex', salary: 1800 }],
internals: [{name: 'Jack', salary: 1300}] internals: [{name: 'Jack', salary: 1300}]
@ -372,7 +372,7 @@ function sumSalaries(department) {
} }
*/!* */!*
alert(sumSalaries(company)); // 6700 alert(sumSalaries(company)); // 7700
``` ```
The code is short and easy to understand (hopefully?). That's the power of recursion. It also works for any level of subdepartment nesting. The code is short and easy to understand (hopefully?). That's the power of recursion. It also works for any level of subdepartment nesting.