Created
November 1, 2022 05:04
-
-
Save justinpage/3ecde132c867029b3fe83a8ae8e5192c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function sumSalaries(salaries) { | |
let sum = 0; | |
for (const salary of Object.values(salaries)) { | |
sum += salary; | |
} | |
return sum; | |
} | |
export function count(user) { | |
return Object.keys(user).length | |
} | |
export function topSalary(salaries) { | |
let top = null; | |
for (let [name, salary] of Object.entries(salaries)) { | |
if (!top) { top = name; } | |
if (salaries[top] < salary) { | |
top = name; | |
} | |
} | |
return top; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment