+ 1
Hi, i need some help making a number game where you generate a random number and then narrowbit down and guess the number
Hulp plz
2 ответов
+ 3
You can use this:
function randomNumberBetween(a, b) {
var minNum = a;
var maxNum = b;
var output = 0;
output = Math.random();
output = output * (maxNum - minNum);
output = output + minNum;
output = Math.round(output);
return output;
}
0
You'll need the Math.
Random gives you 0-1
Round it down
Multiply it by the max number you want
Add 1
And maybe you'll have to change it from string to integer, so you'll have to parse it also.