1function getRandomNumberBetween(min,max){
2 return Math.floor(Math.random()*(max-min+1)+min);
3}
4
5//usage example: getRandomNumberBetween(20,400);
6
1function randomInRange(min, max) {
2 return Math.floor(Math.random() * (max - min) + min);
3}
1function randomRange(min, max) {
2
3 return Math.floor(Math.random() * (max - min + 1)) + min;
4
5}
6
7console.log(randomRange(1,9));
1function getRandomIntInclusive(min, max) {
2 min = Math.ceil(min);
3 max = Math.floor(max);
4 return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive
5}
1function getRandomInt(min, max) {
2 min = Math.ceil(min);
3 max = Math.floor(max);
4 return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
5}
6