Generating random number in JavaScript

Generating random number in JavaScript

Editorial Team
Editorial Team

Follow us on Discord or Telegram to get access to free tutorials and updates.

In JavaScript, you can generate a random number using the random() method. This method returns a number between 0 and 1 (including 0).


<!DOCTYPE html>
    <p id="msparagraph"></p>
    <button onclick="msrandom()">Generate random number</button>

    function msrandom()
        var p=document.getElementById('msparagraph');   


Random number between two values