+ 1
how to make a random number generator? (JS)
Please help me. as simple as possible (JS)
5 Réponses
+ 4
This is the function for you: Math.random. It generates a random bumber between 0 (inclusive) and 1 (exclusive). You can get a random number between two numbers with this "formula":
Math.random() * (max - min) + min
+ 2
You can use that formula but sometimes you will get double result. You need to use Math.ceil().Math.floor() to change them into int
+ 2
in cs...
Random num = new Random();
int x = num.Next(0, 10);
it will generate a number between 0 and 9, but not 10.
+ 1
Thank youu
+ 1
In java also
Random r = new Random();
int rand = r.nextInt(10)