The return value is simply the same array. The code inside the each block gets executed, but the calculated values are not returned.

In contrast, calling the array’s map method returns a new array whose elements are the return values of each round of executing the map block:

Takeaway

If you want to change the return value use map.

If you want to return the original return value use each.

--

--

Live in the moment, be happy (:

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store