To create a random number in javascript you can use the following snippet.

Sample JS

var random=Math.floor((Math.random() * 10) + 1);

Result
A random number between 1 and 10.

fore more informations see W3Schools JavaScript random() Method

2 thought on “How to create a random number in javascript”

Leave a Reply