Created
January 20, 2020 15:07
-
-
Save deepakshrma/8b460e0cd7fbe2d30c20d7af7b704997 to your computer and use it in GitHub Desktop.
[conditionalBreak] Weird Part: How to break the LOOP in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function conditionalBreak() { | |
let x = 0; | |
let z = 0; | |
while (true) { | |
console.log("Outer loops: " + x); | |
x += 1; | |
z = 1; | |
let breakOuterLoop = false; | |
while (true) { | |
console.log("Inner loops: " + z); | |
z += 1; | |
if (z === 10 && x === 10) { | |
breakOuterLoop = true; | |
break; | |
} else if (z === 10) { | |
break; | |
} | |
} | |
if (breakOuterLoop) break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment