Javascript random integer between two numbers

A very simple and useful method to find a random integer between two numbers.  Found this simple javascript function to calculate random integer between two numbers or intervals. Posting here for a quick reference.

Here it is:

[javascript]function randMaxMin(min,max)
{
return Math.floor(Math.random()*(max-min+1)+min);
}
console.log(randMaxMin(1500, 2500));[/javascript]

Leave a Reply