Returns a random integer between min (inclusive) and max (inclusive) - Node.js Number

Node.js examples for Number:Random Number

Description

Returns a random integer between min (inclusive) and max (inclusive)

Demo Code

// Using Math.round() will give you a non-uniform distribution!
 
function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

Related Tutorials