Skip to content

Instantly share code, notes, and snippets.

@dgtlmonk
Created July 22, 2014 06:07
Show Gist options
  • Save dgtlmonk/4155ed4fdece6d7b5e36 to your computer and use it in GitHub Desktop.
Save dgtlmonk/4155ed4fdece6d7b5e36 to your computer and use it in GitHub Desktop.
function getDrink (type) {
var drinks = {
'coke': function () {
return 'Coke';
},
'pepsi': function () {
return 'Pepsi';
},
'lemonade': function () {
return 'Lemonade';
},
'default': function () {
return 'Default item';
}
};
return (drinks[type] || drinks['default'])();
}
getDrink('pepsi');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment