Arraybeginnerconst sparse = new Array(3)
sparse.length // β 3
sparse // β [ <3 empty items> ]Pass a single number to new Array(n) to create a sparse array with a preset length.
When the Array constructor receives a single numeric argument, it creates a sparse array with that many empty slots. The array has the correct length but no actual element values.
Challenge: Implement createArrayOfLength that returns a sparse array of length n.
createArrayOfLength(3) // β [ <3 empty slots> ] (length === 3)
createArrayOfLength(0) // β [] (length === 0)