Skip to content

Instantly share code, notes, and snippets.

@schabibi1
Created February 12, 2019 19:18
Show Gist options
  • Save schabibi1/3f22bfc588124078b6ac5fb0ea5d9739 to your computer and use it in GitHub Desktop.
Save schabibi1/3f22bfc588124078b6ac5fb0ea5d9739 to your computer and use it in GitHub Desktop.
JavaScript: Is Fallthrough From Switch Statement A Troublemaker?
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