matt2099
10/5/2018 - 1:17 PM

While Loop

When the button is clicked the page will output the value of x while x is less than 101

<DOCTYPE html>
<html>
  <head>
      <title> While and Do While Loops</title>
    </head>
<body>
  <script>
  function count()
    {
      var x = 0;
        while(x < 101)
        {
          document.getElementById('output').innerHTML += (x +"<br/>");
          x++;
        }
    }


  </script>
  <p id = "output"></p>
  <button onclick="count()">Count</button>
</body>
</html>