Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Two dimensional arrays
Why did we use an index of 1 for the artise . I thought arrays begin with an index of zero. listHTML += '<li>' + song[i] + ' by ' + song[i] + '</li>';
Jennifer NordellTreehouse Teacher
Hi there! You're absolutely correct. Let's take another look at the play list:
var playList = [ ['I Did It My Way', 'Frank Sinatra'], ['Respect', 'Aretha Franklin'], ['Imagine', 'John Lennon'], ['Born to Run', 'Bruce Springsteen'], ['Louie Louie', 'The Kingsmen'], ['Maybellene', 'Chuck Berry'] ];
So this is an array that contains more arrays. If we were to say
playlist, that would be equal to "Aretha Franklin". Each sub array of the main array contains two indexes. At index of 0 is the title of the song. The index of 1 contains the artist.
Hope this clarifies things!
Yes, it does. Thanks!