const randomArrayInRange = (min, max, n) => Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min);
// Example
randomArrayInRange(1, 100, 10);
const randomNumber = ({ min, max } = { min: 0, max: 1 }) => {
if (min >= max) {
throw Error(
`minimum value (${min}) is larger than or equal to maximum value (${max})`
);
}
return Math.floor(Math.random() * Math.floor(max - min + 1) + min);
};
// Usage: random number between 10 and 100.
const n = randomNumber({ min: 10, max: 100 });