We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fa3cfb3 commit a3f9b97Copy full SHA for a3f9b97
04 - Array Cardio Day 1/index-START.html
@@ -46,16 +46,21 @@
46
47
const firstLast = inventors.map( inventors => `${inventors.first} ${inventors.last}` )
48
49
- console.log(firstLast)
+ // console.log(firstLast)
50
51
// Array.prototype.sort()
52
// 3. Sort the inventors by birthdate, oldest to youngest
53
const oldestToYoungest = inventors.sort((a, b) => a.year - b.year)
54
55
- console.log(oldestToYoungest)
+ // console.log(oldestToYoungest)
56
57
// Array.prototype.reduce()
58
// 4. How many years did all the inventors live all together?
59
+ const yearsLived = inventors.reduce((total, inventor ) => {
60
+ return total + inventor.passed - inventor.year
61
+ }, 0 )
62
+
63
+ console.log(yearsLived)
64
65
// 5. Sort the inventors by years lived
66
0 commit comments