The map method is great for creating data that maps directly to elements from an existing array. However, sometimes, the desired result takes on a different shape. To do this, we can use the reduce method to accumulate values into a new form.
In this recipe, we'll take a look at how to use the reduce method to transform data.