Array Cardio Day One 💪

Array.prototype.map() - Returns a new array containing the results of calling a function on every element in this array.

Array.prototype.filter() - Returns a new array containing all elements of the calling array for which the provided filtering function returns true.

Array.prototype.reduce() - Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value.

Array.prototype.sort() - Sorts the elements of an array in place and returns the array.

methods

Some data we can work with:

Inventors Array People Array Data Array

Exercise 01 - .filter()

Filter the list of inventors for those who were born in the 1500's

Code

Code Exercise 01

Output

Output Exercise 01

Exercise 02 - .map()

Give us an array of the inventors first and last names

Code

Code Exercise 02

Output

Output Exercise 02

Exercise 03 - .sort()

Sort the inventors by birthdate, oldest to youngest

Code

Code Exercise 03

Output

Output Exercise 03

Exercise 04 - .reduce()

How many years did all the inventors live all together?

Code

Code Exercise 04

Output

Output Exercise 04

Exercise 05 - .sort()

Sort the inventors by years lived

Code

Code Exercise 05

Output

Output Exercise 05

Exercise 06 - .map() & .filter()

Create a list of Boulevards in Paris that contain 'de' anywhere in the name from this wikipedia page

Code

Code Exercise 06

Output

Output Exercise 06

Exercise 07 - .sort()

Sort the people alphabetically by last name

Code

Code Exercise 07

Output

Output Exercise 07

Exercise 08 - .reduce()

Sum up the instances of each item on the data array

Code

Code Exercise 08

Output

Output Exercise 08