Code Lab

Mode entretien. Minuteur de 5 min, sans indices ni autocomplétion

Top salary

FacileObjects5 min

Write a function topSalary(salaries). In the object salaries each key is a name and each value is a salary.

Return the name of the person with the highest salary. If the object is empty, return null.

Exemples

topSalary({ John: 100, Pete: 300, Mary: 250 })

Renvoie 'Pete'

topSalary({})

Renvoie null

topSalary({ Ann: 0 })

Renvoie 'Ann'

A salary of 0 counts too.

Source

Chargement de l'éditeur...
  1. EntréetopSalary({ John: 100, Pete: 300, Mary: 250 })
    Attendu'Pete'
  2. EntréetopSalary({})
    Attendunull
  3. EntréetopSalary({ Ann: 0 })
    Attendu'Ann'

Les tests cachés se lancent à la soumission