Skip to content

Commit d8973ae

Browse files
committed
Add solution exercise 4 wesbos#3
1 parent 073e2ff commit d8973ae

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@
5050

5151
// Array.prototype.sort()
5252
// 3. Sort the inventors by birthdate, oldest to youngest
53+
//const ordered = inventors.sort(function(a, b) {
54+
//if(a.year > b.year) {
55+
//return 1;
56+
//} else {
57+
//return -1;
58+
//}
59+
//});
5360

61+
const ordered = inventors.sort((a, b) => a.year > b.year ? 1 : -1);
62+
63+
console.table(ordered);
5464
// Array.prototype.reduce()
5565
// 4. How many years did all the inventors live all together?
5666

0 commit comments

Comments
 (0)