Last active
January 7, 2019 13:42
-
-
Save anthonyec/bd495660a99d56d3417b07dfb2c3954e to your computer and use it in GitHub Desktop.
Ping Pong who is serving
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
function getPlayerServing(totalScore = 0, numberOfServesEach = 2, numberOfPlayers = 2) { | |
return Math.floor((totalScore / numberOfServesEach)) % numberOfPlayers; | |
} | |
// Singles | |
// Player 1 = 0, Player 2 = 1 | |
getPlayerServing(11); | |
// Doubles | |
// Player 1 = 0, Player 2 = 1, Player 3 = 2, Player 4 = 3 | |
getPlayerServing(15, 5, 4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment