JS Methods
Data
An Array of Objects:
const inventors = [
{first: 'Albert', last: 'Einstein', year: 1879, passed: 1955},
{first: 'Isaac', last: 'Newton', year: 1643, passed: 1727},
{first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642},
{first: 'Marie', last: 'Curie', year: 1867, passed: 1934},
{first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630},
{first: 'Nicolaus', last: 'Copernicus', year: 1473, passed: 1543},
{first: 'Max', last: 'Planck', year: 1858, passed: 1947}
];
and a second array (people's names and surnames):
const people = ['Beck, Glenn', 'John, Zuman', 'Linda, Seem', "Lukas, Ronan", 'Mark, Reihard', 'Orlando, Mon', 'Vanessa, Godi', 'Maria, Ruber', 'Robert, Genn', 'Kristof, Tart', 'Karl, Romer', 'Stephan, Gorn', 'Luisa, Bona', 'Andy, Stork', 'Victoria, Munker'];
Here are provided examples of array methods: Map, Filter, Sort and Reduce:
(also you can check the same results in browser's Console (Ctrl+Shift+I)
-
1. Filter
Here are provided filtered results by criteria 'year of birth' between 1500 and 1600
-
2. Map (Full Names)
Here are provided First and Last names of inventors, listed in array as objects
-
3. Sort
Order inverntors by birthday from oldest to youngest
-
Sort (Number)
Sort the inventors by number of years that they lived
-
Sort (Alphabethical order)
Sort the people alphabetically by the first name
-
4. Reduce
How many years all inventors lived in general
-
Reduce (2)
Sum up the instances of each of given items in array (get the number of each the same item)