You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vari,j;
loop1:
for(i=0;i<3;i++){//The first for statement is labeled "loop1"
loop2:
for(j=0;j<3;j++){//The second for statement is labeled "loop2"if(i===1&&j===1){continue loop1;}console.log('i = '+i+', j = '+j);}}// Output is:// "i = 0, j = 0"// "i = 0, j = 1"// "i = 0, j = 2"// "i = 1, j = 0"// "i = 2, j = 0"// "i = 2, j = 1"// "i = 2, j = 2"// Notice how it skips both "i = 1, j = 1" and "i = 1, j = 2"
Using a labeled break with for loops
vari,j;
loop1:
for(i=0;i<3;i++){//The first for statement is labeled "loop1"
loop2:
for(j=0;j<3;j++){//The second for statement is labeled "loop2"if(i===1&&j===1){break loop1;}console.log('i = '+i+', j = '+j);}}// Output is:// "i = 0, j = 0"// "i = 0, j = 1"// "i = 0, j = 2"// "i = 1, j = 0"// Notice the difference with the previous continue example
Endless loop
for(;;){//..}
Get index of array
for(let[index,val]ofarray.entries()){// your code goes here }