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 trial

JavaScript

The Random Challenge - I found this too difficult =(

I got as far as this:

var userNumber = prompt('Type in any number to start!'); document.write(userNumber);

Got totally confused about the random integer and gave up.

I don't feel like I understand the processes well enough to do something like this.

Total fail =(

Well you started Ok! you have your variable working but remember that 'prompt' will return a string. So you need to convert it to a number by using the parseInt method and it would be something like this:

var userNumberConverted=parseInt(userNumber);

then we need to use the Math.random(); method to create a random number and so as to be an intenger (because it gives you a 0.xxx number)we need to convert it using the Math.floor(); method

the random generator code would look like this. Math.floor(Math.random()* userNumberConverted + 1);

Hope this was useful for you!

1 Answer

Give it your best shot! JavaScript is not my forte either, I tried and failed a number of times before my code was perfect. Be maticulous, try something, and if you can't get it to work, and I'd love to help.