Skip to content

Instantly share code, notes, and snippets.

@jamesflorentino
Created August 18, 2013 04:26
Show Gist options
  • Save jamesflorentino/6259890 to your computer and use it in GitHub Desktop.
Save jamesflorentino/6259890 to your computer and use it in GitHub Desktop.
var _dictionary = {
'rock,scissors': 'Rock',
'rock,paper': 'Paper',
'scissors,paper': 'Scissors'
};
function compare(a, b) {
var result;
if (a === b) {
result = 'Result is a tie';
} else {
result = _dictionary[[a,b].join(',')] || _dictionary[[b,a].join(',')];
}
return [result, 'wins!'].join(' ');
}
compare('scissors', 'rock');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment