Others



Random Number in JavaScript


The Math.random() method used to return a random floating number between 0 and 1.

Random Number
var n=Math.random();
Try it Yourself

The following example shows, how to get a random number in given range using JavaScript Math.random() method.

Random Number With Range
var minimum=10000;
var maximum=99999;
var n=Math.floor(Math.random()*(maximum-minimum)+minimum);
Try it Yourself