+ 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

27th Jul 2016, 6:20 PM
matt
matt - avatar
2 Respostas
+ 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; }
4th Oct 2016, 11:55 AM
Sjoerd Flameling
Sjoerd Flameling - avatar
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.
29th Jul 2016, 11:52 AM
Elias Papachristos
Elias Papachristos - avatar