Medium
Understanding the differences between map()
and forEach()
methods in JavaScript
const numbers = [1, 2, 3, 4, 5];
const doubledNumbers1 = numbers.forEach((num) => {
return num * 2;
});
const doubledNumbers2 = numbers.map((num) => {
return num * 2;
});
Author: Vincent CotroStatus: PublishedQuestion passed 2788 times
Edit
Similar QuestionsMore questions about Javascript