0

Как сгенерировать рандомные значения типа int для переменной?

4th Sep 2017, 6:24 PM
Bao Chao
Bao Chao - avatar
6 Answers
+ 15
With this function you can get random integers between min and max values. function getRandomInt(min, max) { var rand = min + Math.random() * (max + 1 - min); rand = Math.floor(rand); return rand; } Example: var a = getRandomInt(0, 10);
4th Sep 2017, 6:41 PM
Igor Makarsky
Igor Makarsky - avatar
0
thanks
4th Sep 2017, 6:35 PM
Bao Chao
Bao Chao - avatar
0
but you translate my text
4th Sep 2017, 6:36 PM
Bao Chao
Bao Chao - avatar