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

Sam DeClerk
Sam DeClerk
3,444 Points

getting NaN whenever I try to render playlist items

Keep getting not a number whenever I try to render the playlist. When I check the console, I don't get any error messages. I can't figure out why the song, or playlist functions are trying to create numbers instead of strings either. I checked the HTML in the dev tools as well and I got the line: <ol id="playlist">NaNNaN</ol>

Here is a snapshot of my whole workspace. https://w.trhou.se/4l1iead4qv

I hate having to give up on this challenge, I'm sure I just forgot a semicolon, or a set of parenthesis.

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Your instinct is correct. It's a tiny error causing the whole problem. On line 27 of song.js you wrote this:

htmlString =+ this.duration;

But you meant to write:

htmlString += this.duration;

Note the reversal of the plus and the equals signs :smiley:

Hope this helps! :sparkles:

Sam DeClerk
Sam DeClerk
3,444 Points

Thank you! I'm dyslexic, so things like that slip past me all the time. Thanks for your help.

Steven Parker
Steven Parker
231,275 Points

Jennifer beat me to it, but in way of explanation, the "+=" operator acts as a concatnating assignment when applied to strings, but by reversing it, it becomes a normal assignment and the "+" in front of the operand forces a numeric conversion. The numeric conversion fails and yields "NaN".