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:
parent
9acc1302a1
commit
642b56329e
1 changed files with 3 additions and 3 deletions
|
@ -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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue