You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Process a collection by visiting each element and do "work" (function()) on it in order to return a new collection or an aggregate value.
map methods return a new Array.
reduce methods return a value.
Map (transformer)
we're going to produce a new Array after "transforming" or applying "work" to each element.
"Map" comes from mathematics where it means:
Taking an independent variable
Plugging it into an equation
Getting a result back
Mathematicians would say you're mapping a value in the domain to a value in the range.
Reduce (aggregator)
we start with an initial value that we'll call the "memo" or "aggregator." Then we do some "work" involving the element and the "aggregator" and that work updates the "aggregator".