I was looking at python script when I have across this:
randomNumber = random.randint(2, number)-1
How can I translate this into javascript?
Thanks?
I was looking at python script when I have across this:
randomNumber = random.randint(2, number)-1
How can I translate this into javascript?
Thanks?
You can use the examples given in the Math.random
docs page,
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
console.log(getRandomInt(2, number) - 1);