0
Q:

javascript get random number

function randomNumber(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;
}
11
// Returns a number between min and max
function getRandomArbitrary(min, max) {
  return Math.random() * (max - min) + min;
}
1
//Write the following code to get a random number between 0 and n
Math.floor(Math.random() * n);
2
// Returns an integer between min and max (the maximum is exclusive and the minimum is inclusive)
function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min) + min); 
}
0
var randomNo = Math.floor(Math.rand() * 10000000001);
console.log(randomNo);

//This will generate random number
0

Math.random()
1

New to Communities?

Join the community