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 trialGraham Davidson
Courses Plus Student 14,966 PointsFundamental Question about Prompts
Morning groovers.
I am learning JavaScript from a very fundamental level up - quick question
When using a prompt and I enter for example the number 8 - will JavaScript always interpret that as in integer - unless I convert it to a string.
G
1 Answer
EDUARDO PARRA SANJOSE
Courses Plus Student 6,718 PointsHi,
No. JavaScript will interpret 8 as a string unless you cast it to a number. The prompt method will return a
- string value if you type something and click OK
- null if you click cancel
- an empty string if you click ok but did not type into the input
For a more complete reference you can check MDN
I hope it was helpful. Many thanks,
Edu