File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 3232 // Array.prototype.filter()
3333 // 1. Filter the list of inventors for those who were born in the 1500's
3434
35+ const fifteen = inventors . filter ( inventor => inventor . year >= 1500 && inventor . year <= 1600 ) ;
36+
37+ //console.table (fifteen);
38+
3539 // Array.prototype.map()
3640 // 2. Give us an array of the inventors' first and last names
37-
41+ const fullNames = inventors . map ( inventor => `${ inventor . first } ${ inventor . last } ` ) ;
42+ //console.log(fullNames);
3843 // Array.prototype.sort()
3944 // 3. Sort the inventors by birthdate, oldest to youngest
40-
45+
46+ const ordered = inventors . sort ( ( a , b ) => a . year > b . year ? 1 :- 1 ) ;
47+ //console.table(ordered);
4148 // Array.prototype.reduce()
4249 // 4. How many years did all the inventors live?
50+ const lived = inventors . reduce ( ( total , inventor ) => { return total + ( inventor . passed - inventor . year ) ;
51+ } , 0 ) ;
52+ console . log ( lived ) ;
4353
4454 // 5. Sort the inventors by years lived
4555
You can’t perform that action at this time.
0 commit comments