Js Generate Random Number

Source URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random

Language: javascript

Created on: 2020-11-25 06:57:01

function getRandomArbitrary(min, max) {
  return Math.random() * (max - min) + min;
}
The Math.random() function returns a floating-point, pseudo-random number in the range 0 to less than 1 (inclusive of 0, but not 1) with approximately uniform distribution over that range — which you can then scale to your desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or reset by the user.
content_copy