Created
February 13, 2016 22:21
-
-
Save huy-tran/0092ae2491b7d33eae6d to your computer and use it in GitHub Desktop.
basic switch syntax
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
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