Created
August 7, 2016 20:54
-
-
Save junior-ales/811a43603cc2f2ff230454ddb77d3367 to your computer and use it in GitHub Desktop.
This file contains 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
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