1function getRandomNumberBetween(min,max){
2 return Math.floor(Math.random()*(max-min+1)+min);
3}
4
5//usage example: getRandomNumberBetween(20,400);
6
1const randomInteger = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
1const min = 1;
2const max = 4;
3const intNumber = Math.floor(Math.random() * (max - min)) + min;
4console.log(intNumber); //> 1, 2, 3
1const randomArrayInRange = (min, max, n) => Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min);
2
3// Example
4randomArrayInRange(1, 100, 10);