Random example of random function of random number generated by js


JavaScript math.random () built-in function The random function returns the value Returns a pseudo-random number between 0 and 1, which may be 0 but is always less than 1, [0,1]. Random function example // returns a random number Document. The write (Math. The random ()); // returns a random number between 10 and 20 Document. The write (Math. The random () * (20 -) 10 + 10); // returns the formula for the specified range of random Numbers (between m-n) Document. The write (Math. The random () * (n - m) + m); Random Numbers can also be generated based on time


var now=new Date();
var number = now.getSeconds(); //This produces an integer from 0 to 59 based on the current time.
var now=new Date();
var number = now.getSeconds()%43; //This produces an integer from 0 to 42 based on the current time.