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
var collectNumber = prompt('Please pick a number')
var collectNumber2 = prompt('Please choose second number')
var collectRealNumber = parseInt(collectNumber);
var collectRealNumber2 = parseInt(collectNumber2);
var collectNumberMin = Math.min( collectRealNumber, collectNumber2 );
var collectNumberMax = Math.max ( collectNumber, collectNumber2 );
var randomNumber = Math.floor(Math.random() * (collectNumberMax - collectNumberMin + 1)) + collectNumberMin;
Jamie ReardonTreehouse Project Reviewer
+1 to Steven's answer! Also since your asking for feedback, you could clean up your code a little by deleting the two "RealNumber" variables by using the parseInt method on the original variables that contain the string input.
var collectNumber = parseInt( prompt('Please pick a number') ); var collectNumber2 = parseInt( prompt('Please choose second number') );
Using less global variables means less memory needed to hold this data in the browser, which is a plus in performance. Also, you are missing a couple of semi-colons. Nothing major of course, but something to get into the habit of!