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

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 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 91,252 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 ;)