From http://www.w3schools.com (Copyright Refsnes Data)

JavaScript random() Method


Math Object Reference JavaScript Math Object

Definition and Usage

The random() method returns a random number between 0 and 1.

Syntax

Math.random()


Example

Example

Return a random number between 0 and 1:

<script type="text/javascript">

document.write(Math.random());

</script>

The output of the code above can be:


Try it yourself »


Math Object Reference JavaScript Math Object

From http://www.w3schools.com (Copyright Refsnes Data)