We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ed2b900 commit ff9ef1eCopy full SHA for ff9ef1e
04 - Array Cardio Day 1/index-START-CF.html
@@ -41,19 +41,19 @@
41
return person.first + " " + person.last;
42
});
43
44
- console.log(firstAndLast);
45
-
46
47
// Array.prototype.sort()
48
// 3. Sort the inventors by birthdate, oldest to youngest
49
- inventors.sort(function(a, b){
50
- a.year > b.year;
51
- });
52
- console.log (inventors);
+ inventors.sort(function(a, b){return a.year - b.year;});
+
53
54
55
// Array.prototype.reduce()
56
// 4. How many years did all the inventors live?
+ const totalYears = inventors.reduce(function(total, person){
+ console.log (person.passed-person.year);
+ return total+(person.passed-person.year);
+ });
+ console.log (totalYears);
57
58
// 5. Sort the inventors by years lived
59
0 commit comments