Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

breaking from a labeled while loop js

let i, 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);
   }
}
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #breaking #labeled #loop #js
ADD COMMENT
Topic
Name
6+5 =