I need to write a code that will look through the data array, and return the name of the oldest person.
console.log('The oldest person is ${oldestPerson}.')
let data = {
{
name: Henry,
age: 20,
job: 'store clerk'
},
{
name: Juliet,
age: 18,
job: 'student'
},
{
name: Luna,
age: 47,
job: 'CEO'
},
So far, I'm able to return separate arrays containing the names and ages, but I'm not sure how to find the oldest age and return name of the oldest person.
let names = data.map((person) => {
return person.name
});
let ages = data.map((person) => {
return Math.max(person.age)
});