JavaScript random

The JavaScript random function returns the Pseudo random numbers between Zero and One and the syntax of this is:


JavaScript math random Function Example

This Function returns the floating point Pseudo random numbers between 0 to 1.

<!DOCTYPE html>
  <h1> JavaScriptMathRANDOM()Function </h1>
  <p id = "P1"></p>
  <p id = "P2"></p>
  <p id = "P3"></p>
  <p id = "P4"></p>
    document.getElementById("P1").innerHTML = Math.random();
    document.getElementById("P2").innerHTML = Math.random();
    document.getElementById("P3").innerHTML = Math.random();
    document.getElementById("P4").innerHTML = Math.random();

The value generated by this is from range 0 (included) and less than 1. If you observe the below screenshot, We called the Math function for four times, and it was returning four different (random) values.

JavaScript RANDOM Function