mapObject
Maps the values of an array to an object using a function.
- Use
Array.prototype.reduce()
to applyfn
to each element inarr
and combine the results into an object. - Use
el
as the key for each property and the result offn
as the value.
Maps the values of an array to an object using a function.
Array.prototype.reduce()
to apply fn
to each element in arr
and combine the results into an object.el
as the key for each property and the result of fn
as the value.