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
Andrew G
7,541 PointsI wrote it this way using less code and it seemed a simpler way to implement, using the DRY principle.
document.write('<h2>My Music Playlist</h2>');
var playList = [ 'Louie Louie ', 'Maybelline ', 'Born to Run ', 'I did it My Way ', 'Respect ', 'Imagine' ]
function printList() {
document.write('<ol>');
for( i = 0; i < playList.length; i++ ) {
document.write('<li>' + playList[i] + '</li>' + '<br/>');
}
document.write('</ol>');
}
printList();
2 Answers
Steven Parker
243,658 PointsWhat code are you comparing this to? Perhaps you could provide a link?
And when 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.
Andrew G
7,541 PointsThanks Steven, the I was comparing to Dave's answer as it was a challenge set by Dave in which he provided his solution in the following episode.
Steven Parker
243,658 PointsProviding a link the page and formatting your code with Markddown would be helpful.