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 trialEmis Zakitis
139 PointsIt doesent give me ordered list.......
PLz help meh it doesn't say anything on the console but doesn't write an ordered list either. plz help me my stuff here It should give me an ordered list?
var playList = [ 'I Did It My Way', 'Respect', 'Imagine', 'Born to Run', 'Louie Louie', 'Maybellene' ];
function print(message) { document.write(message); }
function writeList ( list ) { var listHTML = "<ol>"; for (var i = 0; i < list.length; i++) { listHTML += "<li>" + list[i] + "</li>";
}
listHTML += "</ol>"
print(listHTML);
}
print(playList);
2 Answers
Steve Mustanski
15,093 PointsIt's a little hard to read in the post, but I think the first issue is that the writeList function is never called against the playlist to generate the HTML output. Try changing the last print(playList) call to writeList(playList).
var playList = ['I Did It My Way', 'Respect', 'Imagine', 'Born to Run', 'Louie Louie', 'Maybellene'];
function print(message) {
document.write(message);
}
function writeList(list) {
var listHTML = "<ol>";
for (var i = 0; i < list.length; i++) {
listHTML += "<li>" + list[i] + "</li>";
}
listHTML += "</ol>";
print(listHTML);
}
writeList(playList);
James Estrada
Full Stack JavaScript Techdegree Student 25,866 PointsThe fix that @Steve Mustanski provided you should give you the ordered list. Note that when speaking of an ordered list given by the <ol> tag, it means a list of items preceded by an ordered numeric or alphabetic identifier, not the list itself.
Steven Parker
231,248 PointsSteven Parker
231,248 PointsWhen posting code, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. Or watch this video on code formatting.