I'm trying to write a function that takes as a parameter an array of objects, like this:
function getOldest([{name:john, age:69}, {name:jane, age:28}, {name:paul, age: 19}])
The function would check the age property of the objects and find the largest value, and then return the name property.
getOldest([{name: john, age: 35}, {name: jane, age: 20}, {...}])
returns "john"
Additionally, if two key value pairs share the same value, as in two people have the same age, it would return an array instead.
getOldest([{name: john, age: 20}, {name: jane, age: 20}, {...}])
returns ['john', 'jane']
I've been trying to figure out how to do this for about five hours now but I just can't figure it out.
getOldest()look...trying to write a function- so far you've written the name of a function ... keep trying