Return Random Number Between 0 and 199 with JavaScript



To return a random number between 0 and 199, 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));
      </script>
   </body>
</html>
Updated on: 2020-05-20T10:49:10+05:30

356 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements