javascript

randomization

Published on January 26, 2024By DeveloperBreeze

// 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);

Comments

Please log in to leave a comment.