JavaScript array elements undefined

Hi, I’m quite new to Coding and thus really new here so I’m sorry if I sound like a major newbie, I just can’t seem to figure out what I’m doing wrong here.
This is my code:

let listOfPuppies = ["Shadow, Mocha, Max, Marshmellow"];

listOfPuppies [4] = "Sparky"

For some reason, it prints out 3 empty items in the middle of the array and I can’t seem to figure out why, any help would be appreciated. Thank you!

Java !== JavaScript, they are two completely different languages.

The issue with your code is that there is only one element in the array, so when you assign an element to index 4, the three elements between index 0 and 4 are undefined.

The reason there’s only one element in the array is because you haven’t closed the strings for each item. Try this:

let listOfPuppies = ["Shadow", "Mocha", "Max", "Marshmellow"];