Skip to content
Advertisement

How can I add indexes to array instead of having keys start at zero?

I have an array but the key/indexing showing only zero for all the values instead of 0,1,2,3,4,5. When I print the array, it shows as

JavaScript

Here’s my code

JavaScript

Advertisement

Answer

I think you are looking for something like:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement