javascript get random integer in given range
snippet in javascript

javascript get random floating number

user5363

const randomFloat = (min, max) => Math.random() * (max - min) + min;

javascript get random integer in given range

user3637

const randomInteger = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;

javascript get random array of integre in given range

user7996

const randomArrayInRange = (min, max, n) => Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min);

// Example
randomArrayInRange(1, 100, 10); 

random function javascript

user4887

let object = random(0, 50);
// making "object" a random number between 0 and 50.

console.log(object);
// printing object in the console