CodesJava

Easy learning with example program codes

random math JavaScript JS

The JavaScript math random() method is used to get a random number between 0 and 1 where 0 is included and 1 is excluded.
Syntax:

Math.random()

Returns
a random number between 0 (included) and 1 (excluded).

Example

<!DOCTYPE html>
<html>
<body>
<script>  
document.writeln(Math.random());  
</script>  
</body>
</html>

Output

0.5017130409721287
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status