Created
May 3, 2022 18:29
-
-
Save lmammino/868076ff5d863f88298a86eb4792fdd5 to your computer and use it in GitHub Desktop.
If you ever wanted to use GOTO in JavaScript (for whatever crazy reason)...
This file contains 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
// prints the first 100 even numbers and exits | |
let x = 0 | |
LABEL1: do { | |
console.log(x) | |
x = x + 2 | |
// JUMP TO THE END OF THE DO-WHILE - A FORWARDS GOTO | |
if (x > 100) break LABEL1 | |
// JUMP TO THE START OF THE DO WHILE - A BACKWARDS GOTO... | |
if (x <= 100) continue LABEL1 | |
} while (true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment