jquery random number 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: math.random javascript
Math.random()
Math.floor(Math.random() * 10)
Math.floor(Math.random() * 11)
function randomNum(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
Example 3: javascript random number between 1 and 10
Math.random();
var theRandomNumber = Math.floor(Math.random() * 10) + 1;
Example 4: generate random numbers in js
Math.floor((Math.random() * 100) + 1);
Example 5: random js
function randomNumber(min, max) {
return Math.floor(Math.random() * (max - min)) + min + 1;
}
Example 6: js random generator
var options = ["Your options", "Another option!", "This is an option."];
var chosenOption = Math.floor(Math.random() * options.length);
console.log(options[option]);