如何使用 JavaScript 返回 1 到 200 之间的随机数?
htmljavascriptprogramming scripts更新于 2026/1/13 14:04:17
要返回 1 到 200 之间的随机数,请使用 JavaScript Math.random() 和 Math.floor() 方法。
示例
您可以尝试运行以下代码以在 JavaScript 中返回随机数。
<!DOCTYPE html> <html> <body> <script> document.write(Math.floor(Math.random() * 200) + 1); </script> </body> </html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

