diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 0dcfd00f40..1b65701396 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -35,13 +35,33 @@ 'Berne, Eric', 'Berra, Yogi', 'Berry, Wendell', 'Bevan, Aneurin', 'Ben-Gurion, David', 'Bevel, Ken', 'Biden, Joseph', 'Bennington, Chester', 'Bierce, Ambrose', 'Billings, Josh', 'Birrell, Augustine', 'Blair, Tony', 'Beecher, Henry', 'Biondo, Frank' ]; + + // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + + function filterBday(array, yearTest) { + return array.filter(inventor => inventor.year < yearTest + 100 && inventor.year >= yearTest); + } + + let inventorsFrom1500 = filterBday(inventors, 1500); + // console.log(inventorsFrom1500); + + let inventorsFrom1800 = filterBday(inventors, 1800); + // console.log(inventorsFrom1800); + // Array.prototype.map() // 2. Give us an array of the inventors first and last names + function firstLast (array) { + return array.map(inventor => `${inventor.first} ${inventor.last}`); + } + + let inventorsNames = firstLast(inventors); + console.log(inventorsNames); + // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest