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: W3D TeamStatus: PublishedQuestion passed 4693 times
Edit
120
Community EvaluationsNo one has reviewed this question yet, be the first!
13
Print the number of countries in the array travel.13
Write a Javascript code that displays 'Adversity is not to be feared' and 'There is potentially a real danger'16
The certificate variable is not attainable outside the if loop12
What can be said about ECMAScript?32
Fix the following Javascript loop:50
Write a JavaScript function that fetches data from an API and logs it to the console.13
Use spread operator to split an array into two arrays in Javascript