The array you created with Array(3)
is a sparse array where all elements are empty, and map doesn't call the callback function on the empty elements, so map passes through the array and returns the array unchanged. This is why your code doesn't work