Member-only story
Array.prototype.filter()
1. Filter the list of inventors for those who were born in the 1500's.
const fifteen = inventors.filter(
(inventor) => inventor.year >= 1500 && inventor.year < 1600
);
console.table(fifteen);
2. Array.prototype.map()
Give us an array of the inventor's first and last names.
const fullNames = inventors.map(
(inventor) => `${inventor.first} ${inventor.last}`
);
console.log(fullNames);
3.Array.prototype.sort()
Sort the inventors by birthdate, oldest to youngest
const ordered = inventors.sort((a, b) => (a.year > b.year ? 1 : -1));
console.table(ordered);
4.Array.prototype.reduce()
How many years did all the inventors live?
const totalYears = inventors.reduce((total, inventor) => {
return total + (inventor.passed — inventor.year);
}, 0);
console.log(totalYears);