+ 2
Random with JS
How can i bring things like "randint" (from python) to JS in a easy way?
2 ответов
+ 6
Math.random() will return a number in the range [0, 1)
so if you want a random number in a specific (min, max) range you can create your own function
function randVal(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
+ 4
Is it Math.random()?