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!
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 trial
Marko Delgadillo4,524 Points
Why is it necessary for the first challenge to have parseInt?
My code is as follows and works!
var select=prompt("Select a number MORE than the number 1"); var random= Math.floor( Math.random() * select) +1; var message= random + " is a number between 1 and " + select; document.write(message);
Joe BeltramoCourses Plus Student 22,191 Points
If you are asking why you should use
parseInt() around the variable assigned to the
prompt response (in your case select), it is because the
prompt always returns the value as a string. Anytime you are working with numerical values, you will want them to be actual numerical values as to properly throw or not throw an error when using them.
"1" !== 1