Thursday, October 29, 2015

Nested Loop in JavaScript

In this article I would like to share with you how to write a nested loop in JavaScript using For loop statement. A nested loop is a loop in another loop this kind of looping structure is very useful in some programming problems for example creating a multiplication table we need this one for row and column.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.


Program Listing


<html>
    <head>
        <title> Nested Loop in JavaScript</title>
    <head>
        
    <body      
        <h1> Nested Loop in JavaScript </h1>
        <script>
           for(var x =1; x<=10; x++) {
               document.write(x);
               document.write("<br>");
            }
            
            document.write("<br>");
            
            for (var row = 1; row <= 200; row++) {
                for (var column = 1; column <= 200; column++) {
                    document.write("*   ");
                    
                }
                
                document.write("<br>");
            }
        </script>
</body>
</html>

No comments:

Post a Comment