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) Prototypal Inheritance Building the Movie Object

Martina Carrington
Martina Carrington
15,754 Points

my playlist is not working ?

here is the code i was using .

var playlist = new Playlist();

var hereComesTheSun = new Song ("Here comes the Sun", "The Beatles","2:54");
var walkingOnSunshine = new Song ("Walking on Sunshine", "Katrina and the Waves","3:43");

var manofSteel = new Movie("Man of Steel", 2013, "2:23:00");
playlist.add(hereComesTheSun);
playlist.add(walkingOnSunshine);
playlist.add(manofSteel);

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

playlist.renderInElement(playlistElement);

var playButton = document,getElementById("play");
playButton.oneclick = function() {
  playlist.play();
  playlist.renderInElement(playlistElement);
}


var nextButton = document.getElementById("next);
nextButton.onclick = function() {
 playlist.next();
 playlist.renderInElement(playlistElement);
}

var stopButton = document.getElementById("next);
stopButtonButton.onclick = function() {
 playlist.stop();
 playlist.renderInElement(playlistElement);
}

MOD: Coded edited to add Markdown for readability.

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi martina,

There are a few errors I found in the code provided.

1- With the var playlist, you have typo. You used a comma instead of a period

var playButton = document.getElementById("play");  //changed comma to period between document and getElement

2- At var nextButton, you missed a closing quotation mark in the argument passed in.

var nextButton = document.getElementById("next");       //added closing quotation mark after "next"

3- Same error as #2 with argument passed in on var stopButton.

Fix those up and it should work.

Keep coding! :)

Martina Carrington
Martina Carrington
15,754 Points

oh ok , Thanks Jason Anders , I watch the video three times see why it's wasn't working . thanks

Zac Mackey
Zac Mackey
11,392 Points

Hi Martina!

A couple things - when you post your code it's much easier to read if you use the markdown syntax for code. In this case you would use:

Code Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.

        ```html
        <p>This is code!</p>
        ```

Second, I went through the code you posted and I don't see any errors. However, the problem could reside within your index.html file, or your movie.js file.

Here's a link to my workspace for this challenge:

https://w.trhou.se/779yv7wvg8

EDIT: I linked the wrong workspace initially, here's the correct one!

If you want to you can compare yours to mine and see if you can track down the issue, or if you'll post yours I'll fork it and take a look!

Martina Carrington
Martina Carrington
15,754 Points

Thanks Zac, i had so many error on movie.js , playlist.js and media.js . i had missing quote and ; and '

Zac Mackey
Zac Mackey
11,392 Points

Glad Jason caught those! I must have been looking at my code when I thought I had copied yours. Oops!

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,073 Points

I don't now if anyone mention it but you have wrote "playButton.oneclick = function() {" I think is on line "18" and it should be "onclick" without the "e". I hope it helps.