Skip to content

Instantly share code, notes, and snippets.

@lmammino
Created May 3, 2022 18:29
Show Gist options
  • Save lmammino/868076ff5d863f88298a86eb4792fdd5 to your computer and use it in GitHub Desktop.
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)...
// 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