reduce

Introduction
In this subunit, you'll learn how use the incredibly powerful reduce method! It iterates over an array, but it does not return an array - it can instead return something entirely new like an object or string!
Reduce has some other very cool functionality, which we'll explore. It's a more complicated to use than map and filter, but once you get the hang of it, you'll have an extremely useful tool at your disposal.
Goals
Understand what reduce does
Use reduce to create new data structures
What it does
Whatever is returned from the callback function, becomes the new value of the accumulator!
Accepts a callback function and an optional second parameter
Iterates through an array
Runs a callback on each value in the array
The first parameter to the callback is either the first value in the array or the optional second parameter
The first parameter to the callback is often called "accumulator"
The returned value from the callback becomes the new value of accumulator
Let's Break It Down
Adding A Second Parameter
Let's Try Something Else
When You Would Use Reduce
It works for almost everything, but is sometimes overkill
When you want to transform an array into another data structure