Advertisement
8u

random number JavaScript HTML

8u
Dec 29th, 2021
108
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.47 KB | None | 1 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <h2>JavaScript Math.random()</h2>
  5. <p>Every time you click the button, getRndInteger(min, max) returns a random number between 0
  6. and 9 (both included):</p>
  7. <button onclick="document.getElementById('demo').innerHTML = getRndInteger(0,10)">Click Me</button>
  8. <p id="demo"></p>
  9. <script>
  10. function getRndInteger(min, max) {
  11.   return Math.floor(Math.random() * (max - min)) + min;
  12. }
  13. </script>
  14. </body>
  15. </html>
  16.  
  17. by 8u
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement