While loop:- genius student


while loops can execute a block of code repeatedly as long as a specified condition is true.
Syntax
while(condition) {
    //code block to be executed
}

Code:-

<!DOCTYPE html>
<html>

<head>
 <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>

 <input type="button" onclick="fun_while()" value="Execute while loop">

 <script>
  function fun_while()
  {
   var i = 0;
   while (i < 4)
   {
    alert(i);
    i++; //increment 1 with i value
   }

  }
 </script>

</body>

</html>
While loop:- genius student While loop:- genius student Reviewed by Network security on October 18, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.