javascript generate random numbers code example
Example 1: how to generate a random number in javascript
Math.random();
Math.floor(Math.random())
Math.floor(Math.random() * 10) + 1
Example 2: get random numbers javascript
Math.floor(Math.random() * n);
Example 3: generate random integer javascript
var randomnumber = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
Example 4: generate random int js
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}