Javascript nested for loops

Notes:

JavaScript Nested Loops:

If required we can place one loop inside another loop. This is called as nesting of loops.

Case 2: loops with different max values

for(var i=1; i<=n; i++)
{
for(var j=1; j<=m; j++)
{
sequence of statement(s); // n x m times
}
}

Ex:
for(var i=1; i<=2; i++)
{
for(var j=1; j<=3; j++)
{
document.write(“Hello World <br/>”); // 2 x 3 = 6 times
}
}

Interview Questions: