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

Juan García
Juan García
10,723 Points

Only the first song instance is displayed

Here's my snapshot:

https://w.trhou.se/v6vzv2l86h

I suspect there must be something wrong with the Playlist.prototype.renderInElement function, but after racking my brain I can't come up with a solution.

Any ideas?

Also the buttons don't work either! I'm not sure whether this is related to the previous problem.

Thanks!!

2 Answers

Roberto Alicata
PLUS
Roberto Alicata
Courses Plus Student 39,959 Points

You are right, the problem is in the Playlist.prototype.renderInElement function

you forgot to make a concatenation for the list.innerHTML ( add a plus sign before the equal sign)

list.innerHTML += this.songs[i].toHTML();
Juan García
Juan García
10,723 Points

Thanks for the quick reply Roberto!

Indeed, that solved it. I also found why the buttons didn't work, in the htmlString in the Song.prototype.toHTML I forgot a space at the beginning of ' class="current', so the string it created was

JS
<liclass="current"</li>.

Thanks again!