JavaScript random number between 1 and 10 | Example code

Use Math.random() used with Math.floor() to return get integers (number) between 1 and 10 in JavaScript.

JavaScript random number between 1 and 10 Example code

Complete HTML example code.

Output:

JavaScript random number between 1 and 10

Create a Function for Generate random number

This JavaScript function will returns a random number between min (included) and max (excluded):

Output: 6

Do comment if you have any doubts and suggestion on this example.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.