Created
February 12, 2019 22:01
-
-
Save schabibi1/1138483658b1f6f262f4cc370f8a3afc 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 description = { | |
"Yoda" : "Jedi", | |
"Anakin" : "Jedi", | |
"Obi-One" : "Jedi", | |
"Luke" : "Jedi", | |
"Ray" : "Jedi", | |
"Finn" : "Jedi", | |
"Kylo Ren" : "Jedi", | |
"Chewbacca" : "Wookiee", | |
"R2-D2" : "Astromech droid", | |
"Default" : "Unknown character!" | |
} | |
let result = description[name] || description["Chewbacca"]; | |
console.log(result); // Wookiee |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment