Double for loop
1 Overview
In many cases, a single-layer for loop does not meet our needs. For example, if we want to print a graph with 5 rows and 5 columns, print an inverted right triangle, etc., we can achieve this by nesting the loop.
Loop nesting refers to defining the syntax structure of a loop statement in a loop statement . For example, in a for loop statement, you can nest another for loop. Such a for loop statement is called a double for loop .
// 1. Double for loop syntax structure // for (outer initialization variable; outer conditional expression; outer operation expression) { // for (inner initialization variable; inner conditional expression Yes; inner operation expression) { // // execute statement; // } // } // 2, we can regard the inner loop as the statement of the outer loop // 3, outer loop loop , inside the loop executes all @ 4, code verification, for ( var I =. 1; I <=. 3; I ++ ) { console.log ( 'This is the outer loop's' + i + 'time' ); for ( var j = 1; j <= 3; j ++ ) { console.log ( 'This is the inner loop' + j + 'time' ); } }