Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Using For Loops with Arrays

confused!

Hi can someone explain to me what list[i] does and what it will result in on the webpage. I'm so confused. thanks.

1 Answer

Steven Parker
Steven Parker
229,732 Points

That's just one of the song titles. When you attach a numeric value in brackets to an array name, you are indexing or sub-scripting the array to reference just one of the values. In this case, since the array is a playlist, this will be one of the song titles.

The code in the video is combing it with HTML tags to display it on the page. This is done in a loop so each title is displayed by number order. The result of doing this is demonstrated in the video.