Visitar URL original
Solved #5 Sort the inventors by years lived · wesbos/JavaScript30@1f50dce · GitHub
Skip to content

Commit 1f50dce

Browse files
author
laryl.li
committed
Solved #5 Sort the inventors by years lived
1 parent 3ecdfed commit 1f50dce

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
console.log(year);
6464

6565
// 5. Sort the inventors by years lived
66+
const sortedyearslived = inventors.sort(yearslived);
67+
function yearslived(a,b){
68+
return ((b.passed-b.year)-(a.passed-a.year));
69+
}
70+
console.log(sortedyearslived);
6671

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

0 commit comments

Comments
 (0)