Created
February 12, 2019 19:18
-
-
Save schabibi1/3f22bfc588124078b6ac5fb0ea5d9739 to your computer and use it in GitHub Desktop.
JavaScript: Is Fallthrough From Switch Statement A Troublemaker?
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
let name = 'Ray'; | |
let description = ''; | |
switch(name) { | |
case 'Yoda': | |
case 'Anakin': | |
case 'Luke': | |
case 'Obi-One': | |
case 'Ray': | |
case 'Finn': | |
case 'Kylo Ren': | |
description = 'Jedi'; | |
break; | |
case 'Chewbacca': | |
description = 'Wookiee'; | |
break; | |
case 'R2-D2': | |
description = 'Astromech droid'; | |
break; | |
default: | |
description = 'Unknown character!'; | |
} | |
console.log(description); // Jedi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment