Filter the list of inventors for those who were born in the 1500
const under1600 = inventors.filter( (e) => e.year >= 1500 &&
e.year < 1600 );
Give us an array of the inventory first and last names
const fullNames = inventors.map((e) => e.first +' '+ e.last );
Sort the inventors by birth date, oldest to youngest
const sortedDate = inventors.sort((a, b) => { return a.year -
b.year });
How many yeans did all the inventors live?
const lived = inventors.reduce((acc, n) => { let total = n.passed
- n.year; return acc + total; }, 0);
const sep = inventors.map(e => { return `${e.first} ${e.last}
lived ${e.passed - e.year} years`; });
const ageSorted = inventors.sort((a, b) => { return b.passed -
b.year - (a.passed - a.year); }); console.table(ageSorted);
console.log( ageSorted.map((v) => { return v.passed - v.year; })
);
https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
const category = document.querySelector(".mw-category");
const links = category.querySelectorAll("a");
const de = links .map(link => link.textContent) .filter(streetName
=> streetName.includes('de'));
Sort the people alphabetically by last name
const mapped = people.map((elem) => { return elem.split(",
").reverse().toString().trim(); }); console.table(mapped.sort());
Sum up the instances of each of these
const occur = data.reduce((obj,item)=> { obj[item] = (obj[item] ||
0) + 1; return obj; },{}); console.table(occur);
At least one element has to match to return true else false.
const isAdult = people.some((person) => { const currentYear = new
Date().getFullYear(); return currentYear - person.year >= 19; });
console.log(isAdult);
It returns true if every elements match else false.
const allAdults = people.every((person) => { const currentYear =
new Date().getFullYear(); return currentYear - person.year >= 19;
}); console.log(allAdults);
Find is like filter, but instead returns just the one you are looking for
Find the comment with the ID of 823423
const comment = comments.find((comment) => { return comment.id
=== 823423; }); console.log(comment);
Find the comment with this ID
Delete the comment with the ID of 823423
const comment = comments.findIndex((comment) => { return
comment.id === 823423; }); console.log(comment);