How to return a random number between 1 and 200 with JavaScript?

HTMLJavascriptProgramming Scripts

To return a random number between 1 and 200, use the JavaScript Math.random() and Math.floor() method.

Example

You can try to run 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>
raja
Published on 26-Feb-2018 10:21:07
Advertisements