// Function to generate a random integer between min (inclusive) and max (inclusive)
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Example usage
const minRange = 1;
const maxRange = 100;
const randomNum = getRandomInt(minRange, maxRange);
console.log("Random Number:", randomNum);
code
Generating Random Numbers
This code defines a function getRandomInt that takes a minimum and maximum range and returns a random integer within that range (inclusive). The Math.random() function is used to generate a random decimal between 0 (inclusive) and 1 (exclusive), and Math.floor() is then used to round down to the nearest integer. Adjust the minRange and maxRange variables as needed for your specific range.
Randomization