JS Random

Example

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Math</h2>

<p>Math.floor(Math.random() * 10) returns a random integer between 0 and 9 (both
included):</p>

<p id=”demo”></p>

<script>
document.getElementById(“demo”).innerHTML =
Math.floor(Math.random() * 10);
</script>

</body>
</html>

Output

JavaScript Math

Math.floor(Math.random() * 10) returns a random integer between 0 and 9 (both included):

Updated: February 12, 2019 — 1:00 pm
Java Script © 2019