I have an array with objects and I want to return the object which contains the person who lived the longest. I've gotten this far but I'm stuck now.
const findTheOldest = function(people) {
for (let i = 0; i < people.length; i++) {
people[i].yearOfBirth - yearOfDeath
}
}
const people = [
{
name: "Carly",
yearOfBirth: 1942,
yearOfDeath: 1970,
},
{
name: "Ray",
yearOfBirth: 1962,
yearOfDeath: 2011,
},
{
name: "Jane",
yearOfBirth: 1912,
yearOfDeath: 1941,
},
]