Hey,
Can some one please explain to me why this works:
But the same code with forEach doesn't work?Code:let fruits = ['apple', 'orange', 'lemon']; let output = fruits.map(function(item){ return item; }); console.log(output);
Isn't it that myNames is an array and forEach is a built-in method of Array?Code:let fruits = ['apple', 'orange', 'lemon']; let output = fruits.forEach(function(item){ return item; }); console.log(output);
Why is that the forEach is not working?
Thanks



Reply With Quote
Bookmarks