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 trialGeovani Mejia
Front End Web Development Techdegree Student 7,940 PointsSolution-Feedback. Thanks
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;
document.write(randomNumber);
2 Answers
Steven Parker
231,275 PointsMaking the numbers order-independent was a nice touch.
And for future code postings, use Markdown formatting to preserve your code appearance.
Jamie Reardon
Treehouse 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!
Nice work!