Passed first test in exercise 12
This commit is contained in:
parent
d8d93e38e0
commit
2d76b4cb78
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue