Generate Random Number in JavaScript Between Two Numbers

Hello devs,

javascript random number between two numbers in today's tutorial. In this quick example, I will show you how we can generate random number in javascript between two number like javascript random number between 10 and 100.

I will use math random to generate random numbers in javascript. I will share the source code of javascript random number between range. So let's see the example of math random between two numbers:

Example code:

function getRandomNumbersBetweenRange(min, max) {
    return Math.random() * (max - min) + min;
}

// you can also use

function getRandomNumbersBetweenRange(min, max) {
    return Math.floor(Math.random() * (max - min) + min);
}

 

Hope it can help you.

 

Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js