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

JavaScript Object-Oriented JavaScript (2015) Constructor Functions and Prototypes Making the UI Work

Leo Marco Corpuz
Leo Marco Corpuz
18,975 Points

Creating the list template to html at the beginning of the video.

How does the title/artist list get placed in the ordered list html element without any getElement method?

1 Answer

Steven Parker
Steven Parker
231,269 Points

If you're talking about line 32 (in the video, 33 in your snapshot) of "playlist.js":

  list.innerHTML += this.songs[i].toHTML();

The "list" there is passed in as the argument to the function ("renderInElement"). That call is done on lines 9 and 11 (or 8 and 9) of "app.js":

var playlistElement = document.getElementById("playlist");
playlist.renderInElement(playlistElement);

So the "list" is a result of calling "getElementByID".

If that's not what you meant, please give a more specific reference to what part of the code you're asking about.

Steven Parker
Steven Parker
231,269 Points

Line 16 is the start of the "toHTML" function. It only builds up and returns the string, it doesn't place it in the element. Putting it in the element is done by the code parts I talked about above.