Skip to content

Commit ef65a58

Browse files
committed
Update with sort solution for #5
1 parent 851d588 commit ef65a58

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

04 - Array Cardio Day 1/index-START.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@
5959
console.log(totalYears);
6060

6161
// 5. Sort the inventors by years lived
62-
62+
const oldest = inventors.sort(function(a, b) {
63+
const lastInventor = a.passed - a.year;
64+
const nextInventor = b.passed - b.year;
65+
return lastInventor > nextInventor ? -1 : 1;
66+
});
67+
console.table(oldest);
6368

6469
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
6570
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris

0 commit comments

Comments
 (0)