javascript get random array of integre in given range code example
Example 1: javascript get random number in range
function getRandomNumberBetween(min,max){
return Math.floor(Math.random()*(max-min+1)+min);
}
Example 2: javascript get random integer in given range
const randomInteger = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
Example 3: javascript generate a random integer number in a range of numbers
const min = 1;
const max = 4;
const intNumber = Math.floor(Math.random() * (max - min)) + min;
console.log(intNumber);
Example 4: javascript get random array of integre in given range
const randomArrayInRange = (min, max, n) => Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min);
randomArrayInRange(1, 100, 10);