A Demonstration of a Nested Loop : For « Language Basics « JavaScript DHTML






A Demonstration of a Nested Loop

  

<html>
<head>
  <title>A Demonstration of a Nested Loop</title>
</head><body>
  <script type="text/javascript">
  <!--
    document.write("All x,y coordinates between (0,0) and (9,9):<br>")
   
    for (var x = 0; x < 10; ++x) {
      for (var y = 0; y < 10; ++y) {
        document.write("(" + x + "," + y + "),");
      }
      document.write('<br>');
    }
   
    document.write("<br>After completing the loop, x equals : " + x);
    document.write("<br>After completing the loop, y equals : " + y);
  // -->
  </script>
</body>
</html>



           
         
    
  








Related examples in the same category

1.For loop for lines
2.Check the loop counter
3. Drawing a Christmas Tree Using Nested For Loops
4.For loop
5.Using a for..in Loop in JavaScript
6.A for Loop Used to Count from 0 to 99
7.Using the label Statement
8.Using the continue and break Statements
9.Use of the for Statement
10.The break Statement
11.The continue Statement
12.Labeled Statements
13.Plain for loop
14.For loop with alert dialog
15.Declare for loop counter
16.Control the loop step
17.Use for loop to fill an array
18.Use for in loop to go through an array