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 triallorisanders
5,479 PointsPlaylist items don't show, Uncaught TypeError this.songs[i].toHTML is not a function
I'm pretty sure I've gone through the code with a fine-tooth comb to make this look just like Andrew's, but the console gives me the error in the subject line. Note that my code reads list.innerHTML += this.songs[i].toHTML();
, with parentheses that the error message doesn't pick up (this might be normal, I'm not sure).
Here is a link to my workspace (forked): https://w.trhou.se/an17ecy1z8
It's likely I missed something very smallβI hope someone with sharper eyes can pick it out.
Thanks!
4 Answers
Robert Richey
Courses Plus Student 16,352 PointsHey there,
The problem is with the add
function in playlist.js
.
Playlist.prototype.add = function() {
this.songs.push(Song);
};
The add
function does not have a song
parameter defined, and you're trying to push a copy of the Song
constructor into the songs
array. Here's the fix:
Playlist.prototype.add = function(song) {
this.songs.push(song);
};
Cheers!
Erwin Meesters
15,088 PointsYour playlist.js contains the error. The Playlist.prototype.add function needs a little tweak:
Playlist.prototype.add = function(song) {
this.songs.push(song);
};
lorisanders
5,479 PointsThat was it. Thanks so much!
Tom Emody
1,808 PointsThank you, even if this is old.... I had the exact same issue!
David Elston
8,112 PointsDavid Elston
8,112 PointsHad the same problem and went looking for some help, thanks!