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 trialRichard Boothe
25,204 PointsAdding numbers to parseInt.
This isn't a question, but just more a quick tip to those that are trying to figure out how to add to parsed numbers like I was earlier. Jim doesn't explain this point in this particular video, so I thought I'd post it here to help ease the confusion I had. When adding to a variable that utilizes parseInt, the number being added must be placed outside of the quotation marks and parenthesis. Otherwise, the added number will be added to the end of the parsed numbers, like an additional string. An example:
var j = parseInt("197"); //will return 197.
var jTwo = parseInt("197 + 5"); //will return 1975.
var jThree = parseInt("197") + 5; //will return 202.
I hope this alleviates anyone's confusion that I had when thinking about this method. Good luck to you all.
Nicholas Hebb
18,872 PointsNicholas Hebb
18,872 PointsYou should also specify the radix when using parseInt, e.g.
var j = parseInt("197", 10);
Otherwise, if the string being parsed starts with zero, it will be parsed as an octal.