如何返回介于 0 与 99 之间(都包括)的随机整数

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h2>JavaScript Math</h2>
  6.  
  7. <p>Math.floor(Math.random() * 100)) 返回 0 与 99 之间的随机整数(均包含):</p>
  8.  
  9. <p id="demo"></p>
  10.  
  11. <script>
  12. document.getElementById("demo").innerHTML =
  13. Math.floor(Math.random() * 100);
  14. </script>
  15.  
  16. </body>
  17. </html>