random javasript code example
Example 1: javascript random
function random(min, max) {
return ~~(Math.random() * (max - min + 1) + min);
}
random(1, 5);
Example 2: math random js
function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; // max & min both included
}
Example 3: javascript random()
var randomNo = Math.floor(Math.rand() * 10000000001);
console.log(randomNo);
//This will generate random number