“función para generar un número aleatorio en JavaScript” Código de respuesta

Cómo generar un número aleatorio en JavaScript

//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.
DCmax1k

Generar números aleatorios en JS

Math.floor((Math.random() * 100) + 1);
//Generate random numbers between 1 and 100
//Math.random generates [0,1)
gritter97

Generar el número aleatorio JS

function getRandomIntInclusive(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min + 1)) + min;
}
Outstanding Octopus

Cómo generar un número aleatorio en JavaScript

// min value of the random number
var min = 5;

// max value of the random number
var max = 25;

// generate the random number
var rdm = (Math.random() * (max - min)) + min

// generate the random number without "."
var rdm = Math.round((Math.random() * (max - min)) + min)
Smiling Scarab

Número aleatorio JavaScript

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

Graceful Gharial

función para generar un número aleatorio en JavaScript

function random(number){
    return Math.floor(Math.random()*number);;
}
Vikash Choubey

Respuestas similares a “función para generar un número aleatorio en JavaScript”

Preguntas similares a “función para generar un número aleatorio en JavaScript”

Más respuestas relacionadas con “función para generar un número aleatorio en JavaScript” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código