Created
October 11, 2021 13:07
-
-
Save Blazing-Mike/4ba6d2fb559cb370f2d2fb9421189b4a to your computer and use it in GitHub Desktop.
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
// 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