Ankit Wadhwana
1 min readSep 18, 2019

--

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.

--

--