Please login to start chat

ICT Solutions 22 Jun 2022, 17:57:41
Category : JavaScript Tutorials

Proper Random Function (JS Random)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo">Click Random for random numbers.</p>
<button type = "button" onclick = "myRand()">Random</button>
<script>

function myRand(){
var rand = jsRand(100000, 900000);
document.getElementById("demo").innerHTML = rand;
}

function jsRand(min, max){
return Math.floor(Math.random() * (max - min + 1)) + min;
}
</script>
</body>
</html>

Comments:

No comment to show.

Available Services
Download Android Application