Home > Article > Web Front-end > How to return a random number between 1 and 200 using JavaScript?
To return a random number between 1 and 200, use the JavaScript Math.random() and Math.floor() methods.
You can try running the following code to return a random number in JavaScript.
<!DOCTYPE html> <html> <body> <script> document.write(Math.floor(Math.random() * 200) + 1); </script> </body> </html>
The above is the detailed content of How to return a random number between 1 and 200 using JavaScript?. For more information, please follow other related articles on the PHP Chinese website!