const arr2 = arr.map(double)
How this is working without me passing the array item? I need to pass a parameter to function double: something like double(item)
.
let arr = [1, 2, 3, 4, 5]
function double(x) {
return x * 2
}
const arr2 = arr.map(double)
const arr3 = arr.map(item => double(item))
console.log("arr2= ", arr2)
console.log("arr3= ", arr3)
Output:
arr2 = [2, 4, 6, 8, 10]
arr3 = [2, 4, 6, 8, 10]