Random number generator

Published on

NaN
function getRandom(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; }

This random function includes the lower bound and upper bound. For example, getRandom(1, 10) will generate a random number between 1 and 10 (inclusive).

Usage:

const randomNumber = getRandom(1, 10); // Generates a random number between 1 and 10 console.log(randomNumber); // Example output: 7