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
Matt Bloomer
10,608 Pointsjavascript loops, arrays, and structures
I am on 2 dimensional arrays. My code is not producing what the teacher is producing, and I cannot find what about it is wrong. Can someone please help?
var playList = [ ['I Did It My Way', by 'Frank Sinatra'] ['Respect', by 'Aretha Franklin'] ['Imagine', by 'John Lennon'] ['Born to Run', by 'the Boss'] ['Louie Louie', by 'The Kingsmen']
];
function print(message) { document.write(message); }
function printSongs( songs ) { var listHTML = '<ol>'; for ( var i = 0; i < songs.length; i += 1) { listHTML += '<li>' + songs[i][0} + 'by'+ songs[i][1] + '</li>'; } listHTML += '</ol>'; print(listHTML); }
printSongs(playList);
1 Answer
Jenny Veens
10,896 PointsHi Matt - try removing the word 'by' from each item in the playList array. It looks as though you concatenate it on later in the function printSongs().
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 Pointscan you please repost your code. Please review the Markdown Cheat sheet (the cheat sheet is located just above the post comment button) on how to do this. Its very difficult to read the code provided. thanks.