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 trialBei Mi Chen
Full Stack JavaScript Techdegree Student 6,720 PointsNoob here. Will this do?
alert("You will receive a number between 1 and the number you are thinking.")
var userNumber= prompt("What number are you thinking?");
var numberX = (Math.floor(Math.random() * (parseInt(userNumber)))) + 1;
document.write("Your number is " + numberX)
p.s. no idea how i am meant to post my code lol
2 Answers
Chunwei Li
18,816 PointsHi Chen,
Do you mean how to post code in the forum?
If so, I think you don't need double slash(//).
alert("You will receive a number between 1 and the number you are thinking.")
var userNumber= prompt("What number are you thinking?");
var numberX = (Math.floor(Math.random() * (parseInt(userNumber)))) + 1;
document.write("Your number is " + numberX)
Sincerely,
Michael Lambert
8,272 PointsOne thing I would suggest, you can essentially combine the first 2 lines into 1