Skip to content

Instantly share code, notes, and snippets.

@junior-ales
Created August 7, 2016 20:54
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 junior-ales/811a43603cc2f2ff230454ddb77d3367 to your computer and use it in GitHub Desktop.
Save junior-ales/811a43603cc2f2ff230454ddb77d3367 to your computer and use it in GitHub Desktop.
var getScore = function() {
var s;
if ((player1Score < 4 && player2Score < 4) && (player1Score + player2Score < 6)) {
var p = ['Love', 'Fifteen', 'Thirty', 'Forty'];
s = p[player1Score];
return (player1Score === player2Score) ? s + '-All' : s + '-' + p[player2Score];
} else {
if (player1Score === player2Score)
return 'Deuce';
s = player1Score > player2Score ? player1Name : player2Name;
return ((player1Score - player2Score) * (player1Score - player2Score) === 1) ? 'Advantage ' + s : 'Win for ' + s;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment