Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Promoted
Duaa-07
Lv 6
how to use Math.random() and Math.floor() in javascript to generate a random number between 30 and 90 ?
3 Answers
Relevance
- ?Lv 79 years agoFavorite Answer
https://developer.mozilla.org/en-US/docs/JavaScrip...
// Returns a random integer between min and max
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
- Dominic
- TheMadProfessorLv 79 years ago
Is it a must that you use floor()? Why not generate a random between 0 and 60, then just add 30 to it?
Still have questions? Get your answers by asking now.