Math.random()
static method returns a floating-point, pseudo-random number that's greater than or equal to 0
and less than 1
function getRandomInt(max) { return Math.floor(Math.random() * max); } console.log(getRandomInt(3)); // Expected output: 0, 1 or 2
function getRandomArbitrary(min, max) { return Math.random() * (max - min) + min; }
Math.random()
does not provide cryptographically secure random numbers