function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}
<script>
// Function to generate random number
function randomNumber(min, max) {
return Math.random() * (max - min) + min;
}
document.write("Random Number between 1 and 5: ")
// Function call
document.write( randomNumber(1, 5) );
</script>