Need Help With Easy Code

I am trying to make a random number generator that can generate any number from 100 to 255. If anyone would be willing to explain/give that code, it would be very much appreciated. Thanks!

1 Like

Hey there, try using the code playground on our website, where you can type out your own code. That way you can use JavaScript that we don’t have keys for in our mobile app.

For a random number generator, take a look at some of the Math methods that are built in to JavaScript. By combining a few of them, you should be able to create the function you’re looking for without too much trouble!

In particular, pay attention to Math.random(), which generates a random number between 0 and 1.

You can then multiply this number to scale it up. For example, Math.random() * 100 will generate a number between 0 and 100.

To generate a number between 100 and 255, you could generate a random number between 0 and 155, then add 100.

Other methods that might be helpful are:

Good luck! Post your code here once you’re finished!
Ben

1 Like