Welcome to this interesting lesson! We're going to explore JavaScript array methods, specifically: forEach(), map(), filter(), reduce(), and find().
JavaScript arrays can store multiple values. Array methods enable us to perform operations such as modifying or searching array elements. To call array methods, you use dot-notation on the array. For example: arrayVar.arrayMethod(func).
Array Methods accept a function as a parameter either using the => operator or passing the function name. For example:
To inspect each element in an array, we use the forEach() method, which runs a function on each array element.
The forEach() method accepts a function as a parameter, using the => operator,
and runs the function on each element of the array. If we just want the value of each element in the array, we specify the input to our function as just (star).
If we want the value of each element and its index, we specify the input as
(star, index).
The map() method transforms data and creates a new array based on the results of a function.
Just like forEach(), map takes in a function as an input. map() returns an array
where each element is the value returned by calling our function on that element.
