1// Between any two numbers
2Math.floor(Math.random() * (max - min + 1)) + min;
3
4// Between 0 and max
5Math.floor(Math.random() * (max + 1));
6
7// Between 1 and max
8Math.floor(Math.random() * max) + 1;
1function randomInRange(min, max)
2{
3 return Math.floor(Math.random() * (max - min + 1) + min);
4}
1Math.floor(Math.random() * (max - min + 1)) + min;
2
3// Between 0 and max
4Math.floor(Math.random() * (max + 1));
5
6// Between 1 and max
7Math.floor(Math.random() * max) + 1;