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 trialKen Cherry
1,147 PointsShouldn't songs.length in the for loop be playList.length since the name of the array is playList?
Shouldn't songs.length in the for loop be playList.length since the name of the array is playList? If not, please help.
var playList = [ [ "", "", ""], [ "", "", ""] ];
for( i = 0; i < songs.length; i += 1 ) { }
1 Answer
Steven Parker
229,204 PointsWhat you're saying certainly seems to go with that code snippet, but if these lines are part of a larger project, there could be other things involved. If this is from a course, please provide a link to the course page you are working with.
Omar Faruque
Full Stack JavaScript Techdegree Graduate 21,802 PointsOmar Faruque
Full Stack JavaScript Techdegree Graduate 21,802 PointsIf you want to iterate through an array named songs, then it should be songs.length. Here, I guess you want to iterate through the playList array. So, yes, it should be playList.length. By the way, use the var inside the loop conditional. Example:- for( var i = 0; i < songs.length; i += 1 ) { }