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 trialamz baz
2,053 Pointswhy isn't 3.14 recognised as a number?
I want to get the value of PI as answer of 3.14 but when I answer all three of my questions right i get 2/3 score. So my question is why is 3.14 not recognised as a number?
2 Answers
Emmanuel Molina
9,268 PointsWe need more info to anwser but I guess you captured the user's answer as a text input and don't parse it into a number before testing it.
use Number() before the test and don't forget to think as NaN as a possible result
Emmanuel Molina
9,268 PointsOk I see your mistake
```parseInt() return an integrer => open console > parseInt(3.14) > 3
parseFloat() will return a decimal => open console parseFloat(3.14) > 3.14
Number() will also return a decimal => open console Number(3.14) > 3.14```
amz baz
2,053 PointsI completely forgot about praseFloat thanks for the reminder :)
amz baz
2,053 Pointsamz baz
2,053 PointsHi, I did use parseInt before the prompt command like below: response = parseInt(prompt(question));
I'll try the number() and NaN. Thanks.