Array.prototype.mapbeginnerconst nums = [1, 2, 3]
nums.map(n => n * 2) // β [2, 4, 6]Use map() to transform every element of an array and collect the results in a new array.
Array.prototype.map(callback) creates a new array populated with the return values of calling callback on every element of the original array. The original array is not mutated.
Challenge: Implement double(nums) that returns a new array where every number is multiplied by 2.
double([1, 2, 3]) // β [2, 4, 6]
double([0, -1, 10]) // β [0, -2, 20]