Question from the Javascript - Fundamentals test

Understanding the differences between `map()` and `forEach()` methods in JavaScript

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 1852 times
Edit
32
Community Evaluations
developer avatar
Florian
19/03/2023
Simple et efficace pour rafraichir les bases
developer avatar
HĂ©lĂšne
11/12/2023
C'est pour ça qu'on a besoin d'utiliser map dans React. On veut obtenir un tableau d'éléments JSX à partir d'un tableau de données.
developer avatar
Nadia
14/04/2023
Bon Ă  savoir, merci !