Aug 27, 2017 · 1 min read
This is a bad example of what map is used for, since, as a side effect, your callback is modifying the elements in the original collection. If you want to change collection elements, using collection.forEach() is the cleaner approach.
You can fix your example if your callback first makes a copy of person before setting the coffeeLover property on the copy.
