Array.prototype.forEachintermediateconst result = [1, 2, 3].forEach(n => n * 2)
console.log(result) // β undefinedforEach() always returns undefined β use map() instead if you need a new array.
No matter what the callback returns, forEach always returns undefined. This distinguishes it from map, filter, and reduce.
Challenge: Implement forEachReturns(arr) that calls forEach on the array and returns its return value (which will always be undefined).
forEachReturns([1, 2, 3]) // β undefined