Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 90,705 Points

OOP JavaScript Course: PlayList example

I'm about 5 minutes into the video but I haven't been following it correctly and thus I've just spent the last hour debugging it and this is my snapshot so far.

http://w.trhou.se/wqoh8p2rz0

If you fork it out, you can see that I'm almost there but I keep getting NaNNaN where the titles of the songs should be. I'm out of ideas I'm afraid, any idea what could be up?

1 Answer

Grace Kelly
Grace Kelly
33,990 Points

Hi Jonathan, I notice in your song.js file you have "=+" instead of "+=" when adding to the htmlString variable, I would start by rectifying that:

if(this.isPlaying) {
    htmlString += ' class="current"'; //only add class of current if the song is playing
  }
  htmlString += '>'; //use += 
  htmlString += this.title;
  htmlString += ' - ';
  htmlString += this.artist;
  htmlString += '<span class="duration">';
  htmlString += this.duration; 
  htmlString += '</span></li>'; 

  return htmlString;  //return string to function
};

Hope that helps!!

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 90,705 Points

Hi Grace,

Sorry it took so long for me to respond but yup, you were right! I thought i'd fixed that before but it's such a simple thing to miss ;)