generate a random whole number in JavaScript code example
Example 1: javascript get random number
// Returns a number between min and max
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
Example 2: javascript random
function random(min, max) {
return ~~(Math.random() * (max - min + 1) + min);
}
random(1, 5);