Home / DeveloperSection / Blogs / Using JavaScript Nested Loops

Using JavaScript Nested Loops

Danish Khan 23425 09-Nov-2012


In this blog I am going to explain the use of nested for loops in JavaScript.

<html xmlns="">
    <title>Nested loops in JavaScript</title>
    <script type="text/javascript">
        var i, j, mulTot;
        for (i = 1; i <= 15; i++) {
            for (j = 1; j < 15; j++) {
                mulTot = i * j;
                if (mulTot < 10) {
                    mulTot = " " + mulTot;
                else {
                    mulTot = " " + mulTot;


Using JavaScript Nested Loops

Nested loops are used in most of the places it is used in Matrix multiplication,  Displaying tables and many other places. In this example first the outer loop is initialized and if the condition  is true it will give control to the inner loop and this inner loop will keep on incrementing till the condition of the inner loop is true and when the condition of the inner loop becomes false then only the control will be transferred to the outer loop.


Through this blog we came to know about how to use multiple loops in our program.

Updated 18-Sep-2014

Leave Comment


Liked By