JavaScript tutorial 70 – nested loops in javascript



JavaScript tutorial 70 – nested loops in javascript

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
}
}

=========================================

Follow the link for next video:
JavaScript tutorial 71 – linear, quadratic, cubic & dependent quadratic loops

Follow the link for previous video:
JavaScript tutorial 69 – nesting loops in javascript | nested for loops

====== JavaScript Questions & Answers ========

=========================================

Original source

12 thoughts on “JavaScript tutorial 70 – nested loops in javascript

Leave a Reply