'Javascript map method

Does the map method always use a return statement?

Because in this example, there is a return statement showing in the myFunction function:

const numbers1 = [45, 4, 9, 16, 25];
const numbers2 = numbers1.map(myFunction);

function myFunction(value, index, array) {
  return value * 2;
}


Solution 1:[1]

if you use arrow functions you don't have to add return but you use regular functions like above your instaces you have to add return you don't return you will get undefined or null.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 diyarovski