File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 3838
3939 // Array.prototype.filter()
4040 // 1. Filter the list of inventors for those who were born in the 1500's
41+ const inventorsBornIn1500s = inventors . filter ( inventor => inventor . year >= 1500 && inventor . year < 1600 ) ;
42+ console . table ( inventorsBornIn1500s ) ;
43+
4144
4245 // Array.prototype.map()
4346 // 2. Give us an array of the inventors first and last names
47+ const inventorFullNames = inventors . map ( ( inventor ) => inventor . first + " " + inventor . last ) ;
48+ console . table ( inventorFullNames ) ;
4449
4550 // Array.prototype.sort()
4651 // 3. Sort the inventors by birthdate, oldest to youngest
52+ const byBirthDate = inventors . sort ( ( a , b ) => a . year - b . year ) ;
53+ console . table ( byBirthDate ) ;
4754
4855 // Array.prototype.reduce()
4956 // 4. How many years did all the inventors live all together?
57+ const totalYears = inventors . reduce ( ( total , inventor ) => {
58+ return total + ( inventor . passed - inventor . year ) ;
59+ } , 0 ) ;
60+ console . table ( totalYears ) ;
5061
5162 // 5. Sort the inventors by years lived
5263
You can’t perform that action at this time.
0 commit comments