Skip to content

Instantly share code, notes, and snippets.

@Blazing-Mike
Created October 11, 2021 13:07
Show Gist options
  • Save Blazing-Mike/4ba6d2fb559cb370f2d2fb9421189b4a to your computer and use it in GitHub Desktop.
Save Blazing-Mike/4ba6d2fb559cb370f2d2fb9421189b4a to your computer and use it in GitHub Desktop.
// writing if statements as swich statements
//This IF/ELSE statement
if(x === 'value1'){
...
} else if (x = 'value2'){
...
} else{
...
}
// Rewritten as SWITCH STATEMENT
switch(x) {
case 'value1': // if (x === 'value1')
...
[break]
case 'value2': // if (x === 'value2')
...
[break]
default:
...
[break]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment