← Back to challenges

Who's The Oldest?

JavaScriptHarddata_structuresobjectslanguage_fundamentals

Instructions

Given an object containing the names and ages of a group of people, return the name of the oldest person.

Examples

oldest({
  Emma: 71,
  Jack: 45,
  Amy: 15,
  Ben: 29
}) ➞ "Emma"

oldest({
  Max: 9,
  Josh: 13,
  Sam: 48,
  Anne: 33
}) ➞ "Sam"

Notes

All ages will be different.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.