DeveloperBreeze

Generating Random Numbers

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

Continue Reading

Handpicked posts just for you — based on your current read.

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!