Write a function map(arr, fn) without the built-in Array.prototype.map.
It returns a new array where each element is replaced by fn(arr[i], i). The callback fn gets the element and its index. Do not change the input array.
map([1, 2, 3], (n) => n + 1)Returns [ 2, 3, 4 ]
map([10, 20, 30], (n, i) => n * i)Returns [ 0, 20, 60 ]
Hidden tests run on Submit.