Random Method in Js

 * JavaScript has a built-in  function for generating numbers: Math.random().

Math.random() returns a float between 0 and 1.

* To generate random integers or numbers greater than 1, multiply or add with some constant number.

example : 

1
2
3
Math.random() * 100; // floats between 0 and 100 (please note, this statement, at a time it will generate only one number)
Math.random() * 25 + 5; // floats between 5 and 30
Math.random() * 10 - 100; // floats between -100 and -90

Application area:
To simulate conditions.

Comments