Skip to content

Instantly share code, notes, and snippets.

@deepakshrma
Created January 20, 2020 15:05
Show Gist options
  • Save deepakshrma/a81758b8dce80d0da579e963d32d2753 to your computer and use it in GitHub Desktop.
Save deepakshrma/a81758b8dce80d0da579e963d32d2753 to your computer and use it in GitHub Desktop.
[labeledLoop] Weird Part: How to break the LOOP in JavaScript
function labeledLoop() {
let x = 0;
let z = 0;
outer: while (true) {
console.log("Outer loops: " + x);
x += 1;
z = 1;
while (true) {
console.log("Inner loops: " + z);
z += 1;
if (z === 10 && x === 10) {
break outer;
} else if (z === 10) {
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment