A real world reduce() example

For a long time I couldn’t think of a reasonable way to use reduce beyond the classic sum example (taken from MDN)

A few days ago, I found a way to make reduce() actually useful to me. I have been using it to create a new array out of an array of objects.

I had an array of complex objects, and I wanted to just get an array containing one of those properties, the name.

Not sure why I never thought of this before, but better late than never, right?

Leave a Reply

Your email address will not be published. Required fields are marked *