How to create a random number between two values in JavaScript?

0
558
views

Generating a Random no in Javascript

We can use the Math.random() function for our random behaviour then create a function such as:

function randomRange(min,max) {
	return Math.random() * (max-min) + min;
}
 
var n = randomRange(10,20);
console.log( n );

LEAVE A REPLY

Please enter your comment!
Please enter your name here