What you need to know
map returns a new array containing the result of each callback. forEach returns undefined and is intended for side effects such as logging or updating an external accumulator.
How to apply it
If the next step needs a transformed list, return a value from map and use that list. If you only need to perform an action for each item, use forEach or a loop that makes the effect clear.
Common mistake to avoid
Do not call map and ignore its returned array. That communicates the wrong intent and may allocate a list you never use.
