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

So far as I can make out this should work however it's telling me that playlist.add() is not a function.

Steven Parker
Steven Parker
231,275 Points

That's a private URL to your workspace, it's temporary and only exists while you are using it.

:information_source: But you can use the snapshot function in the workspace and provide the link to that.

I actually worked it out. It was as simple as playList instead of playlist. Thanks for the input though.

Steven Parker
Steven Parker
231,275 Points

Cool, so I actually did guess it! And congratulations on resolving it. :+1:

3 Answers

Steven Parker
Steven Parker
231,275 Points

Perhaps a bad value in "playlist"?

Without seeing the code, this is just a guess, but maybe when this error occurs the "playlist" variable does not actually contain a Playlist object. Perhaps it has undefined or null?

make sure it looks like this:

// this prototype function receives a 'song' value
Playlist.prototype.add = function(song) {
  this.songs.push(song);
};
Thomas Faller
Thomas Faller
9,640 Points

Can you check that you have playlist.add(.... in app.js and not Playlist.add(... ?