In Javascript you have a number of functions to genrate random numbers between two given digits. Some of them are inbulit and some you can create for your own, But the simplest way to perform the operation is the code below:-
// Returns a random integer between min and max
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
And this way it will perfom
// 5 - 20
Math.floor(Math.random() * 16) + 5;
Source: Mozilla Developers
0 Comment(s)