x
 
1
<!DOCTYPE html>
2
<title>My Example</title>
3
4
5
<p id="msg"></p>
6
<p>Because <code>Math.random()</code> returns a floating-point number, we can multiply it, then use <code>Math.floor()</code> to return the largest integer less than or equal to the random number. This provides a more uniform distribution than using <code>Math.round()</code>.</p>
7
8
<script>
9
  document.getElementById("msg").innerHTML = Math.floor(Math.random( 1, 100 ) * 100);
10
</script>