Sponsored Links

December 5, 2017

How to Generate Random Number within the range

This example shows how to generate random number from the range of number given.
function generateRandomNumber(minNum, maxNum) {
        return Math.floor(Math.random() * (maxNum- minNum+ 1)) + minNum;
}
generateRandomNumber(5, 15);

Above code will generate random number between 5 and 15.

No comments:

Post a Comment