Math.random() in javascript

     The Math.random() function returns a floating-point, pseudo-random number in the range [0, 1] that is, from 0 (inclusive) up to but not including 1 (exclusive), 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.

Note:  Math.random() does not provide cryptographically secure random numbers. Do not use them for anything related to security. 

Syntax

   Math.random();
Example

   Math.random();  //0 to 1 Numbers

   (Math.floor(Math.random() * 100) + 1) // 1 to 100 Numbers


Example Program:- (Editor)


Editor is Loading...

Advertisement

0 nhận xét:

Đăng nhận xét