1function getRandomNumberBetween(min,max){
2 return Math.floor(Math.random()*(max-min+1)+min);
3}
4
5//usage example: getRandomNumberBetween(20,400);
6
1function randomRange(min, max) {
2
3 return Math.floor(Math.random() * (max - min + 1)) + min;
4
5}
6
7console.log(randomRange(1,9));
1const min = 1;
2const max = 4;
3const intNumber = Math.floor(Math.random() * (max - min)) + min;
4console.log(intNumber); //> 1, 2, 3
1var randomWholeNumber = Math.floor(Math.random() * 20);
2
3
4function randomWholeNum() {
5
6 return Math.floor(Math.random() * 10);
7
8}
9
10console.log(randomWholeNum());
1var myMin = 1;
2var myMax = 10;
3function randomRange(myMin, myMax) {
4 return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin;
5}
6
7console.log(randomRange(myMin, myMax));