Passed first test in exercise 12

This commit is contained in:
NetMan 2024-01-11 21:52:09 +01:00
parent d8d93e38e0
commit 2d76b4cb78
1 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,10 @@
const findTheOldest = function() { const findTheOldest = function(array) {
const oldest = array.sort((a, b) => {
let ageA = a.yearOfDeath - a.yearOfBirth;
let ageB = b.yearOfDeath - b.yearOfBirth;
return (ageA > ageB) ? -1 : 1;
})[0];
return oldest;
}; };
// Do not edit below this line // Do not edit below this line