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