This site runs best with JavaScript enabled.

Javascripts map

Kevin Beck

May 08, 2020

"The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

You shouldn't be using the map() method if:

you're not using the array it returns; and/or you're not returning a value from the callback." MDN

const array1 = [1, 4, 9, 16];
// pass an arrow function (times each value by two) to map
const array2 = => x * 2);
// expected output: Array [2, 8, 18, 32]