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 trialUnsubscribed User
4,829 PointsNothing is printing, can someone check my syntax?
var playList = [ 'I Did It My Way', 'Respect', 'Imagine', 'Born to Run', 'Louie Louie', 'Maybellene' ];
function print(message) { document.write(message); }
function printList( list ) { var listHTML = '<ol>'; for ( var 1 = 0; i < list.length; i += 1 ) { listHTML += '<li>' + list[i] + '</li>';
} listHTML += '</ol>'; print(listHTML); } printList(playList);
2 Answers
Tim Renner
11,163 PointsI believe this question addresses the same problem
Basically, the browser behavior for document.write() has changed since the tutorial was written.
Keep on coding!
Unsubscribed User
4,829 PointsI found it, I had
var 1 = 0 instead of var i = 0.
Tim Renner
11,163 PointsGood job figuring it out even though my suggestion was wrong. When you post code, use markdown so it's easier to read in the forum. Here's how (see Markdown Cheatsheet for more):
Wrap your code with 3 backticks (```) on the line before and after...
var playList = [ 'I Did It My Way', 'Respect', 'Imagine', 'Born to Run', 'Louie Louie', 'Maybellene' ];
function print(message) {
document.write(message);
}
function printList( list ) {
var listHTML = '<ol>';
for ( var i = 0; i < list.length; i += 1 ) {
listHTML += '<li>' + list[i] + '</li>';
}
listHTML += '</ol>';
print(listHTML);
}
printList(playList);