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 trialSam DeClerk
3,444 Pointsgetting 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
Treehouse TeacherHi 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
Hope this helps!
Steven Parker
231,275 PointsJennifer 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".
Sam DeClerk
3,444 PointsSam DeClerk
3,444 PointsThank you! I'm dyslexic, so things like that slip past me all the time. Thanks for your help.