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 trialLaura Henneberry
1,808 PointsWouldn't the answer be Syntax Error, because .5 is not a whole number?
for console.log( parseInt( '.5 FTE' ));
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Laura,
parseInt will attempt to convert the string into an integer. If the first character can't be converted into a digit then it will return NaN
- Not a Number
Since the period can't be converted to a digit it returns NaN.
If the string was '1.5 FTE' instead then it would return the number 1. The character 1 can be converted to a digit but the period can not so it stops right there.
Here's the mdn page on it if you'd like to read more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
Jacob Mishkin
23,118 Pointsinstead of using the parseInt() function, you might want to try using parseFloat(), .5 is a floating number and not an integer.
here is more on parseFloat()