javascript random number between 1 and 10
snippet in javascript

how to generate a random number in javascript

user4585

//To genereate a number between 0-1
Math.random();
//To generate a number that is a whole number rounded down
Math.floor(Math.random())
/*To generate a number that is a whole number rounded down between
1 and 10 */
Math.floor(Math.random() * 10) + 1 //the + 1 makes it so its not 0.

javascript random number

user8451

var RandomNumber = Math.ceil(Math.random() * 100);              
// Returns a random number between 1 and 100

random js

user5445

function randomNumber(min, max) {
  return Math.floor(Math.random() * (max - min)) + min + 1;
}

javascript random number between

user2592

Math.floor(Math.random() * 6) + 1  

generate random number javascript

user9418

function randomNumber(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;
}

javascript random number between 1 and 10

user2529

// Genereates a number between 0 to 1;
Math.random();

// to gerate a randome rounded number between 1 to 10;
var theRandomNumber = Math.floor(Math.random() * 10) + 1;