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
My Random Challenge Solution - Thoughts?
alert ('Hello. I will now predict your lucky number for today.'); var number1 = prompt ('Please give me a number.'); number1 = parseInt(number1); var number2 = prompt ('Please give me another number.'); number2 = parseInt(number2); var randomNumber = Math.floor (Math.random () * number1 * number2) + 1; alert ('Your lucky number today is . . . '+ randomNumber);
This is my first time posting a question with code, so just in case I did it wrong, here is the link.
Steven Parker228,025 Points
You didn't provide a link to the page, but typically the objective would be generate a random value that is between the supplied numbers. The formula to do that is:
Math.floor(Math.random() * (highlimit - lowlimit + 1)) + lowlimit;
Then, you'd either need some extra code to identify which of the numbers was higher, or you could just change the prompts to specifically ask for a higher number and a lower one.