Skip to content

Instantly share code, notes, and snippets.

@huy-tran
Created February 13, 2016 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huy-tran/0092ae2491b7d33eae6d to your computer and use it in GitHub Desktop.
Save huy-tran/0092ae2491b7d33eae6d to your computer and use it in GitHub Desktop.
basic switch syntax
function getHobbyOf(name) {
var hobby;
switch (name) {
case 'Huy':
hobby = 'Guitar';
break;
case 'Tram':
hobby = 'Photography';
break;
default:
hobby = 'Out of survey';
}
return hobby;
}
getHobbyOf('Tram'); // log 'Photography'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment