Skip to content

Instantly share code, notes, and snippets.

@justinpage
Created November 1, 2022 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinpage/3ecde132c867029b3fe83a8ae8e5192c to your computer and use it in GitHub Desktop.
Save justinpage/3ecde132c867029b3fe83a8ae8e5192c to your computer and use it in GitHub Desktop.
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