1function getRandomNumberBetween(min,max){
2 return Math.floor(Math.random()*(max-min+1)+min);
3}
4
5//usage example: getRandomNumberBetween(20,400);
6
1const rnd = (min,max) => { return Math.floor(Math.random() * (max - min + 1) + min) };
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}
1const randomInteger = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
1function randomInt(min, max) {
2 return Math.floor(Math.random() * (max - min + 1) + min)
3}
4
5console.log(randomInt(1, 6)) // random integer between 1 and 6