Created
April 22, 2022 18:24
-
-
Save James1x0/2a06e718c86263c9a7dc12ccc98fd39e to your computer and use it in GitHub Desktop.
I play next on a reverse in uno, change my mind
This file contains hidden or 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
let currentTurn = 3; | |
const players = [ | |
'you', | |
'someone', | |
'me' | |
]; | |
function logCurrentPlayer () { | |
return players[(currentTurn % players.length) - 1]; | |
} | |
function nextTurn () { | |
// next turn | |
currentTurn++; | |
} | |
// plays on turn | |
players.reverse(); | |
nextTurn(); | |
logCurrentPlayer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bug in the code. whenever
currentTurn
is a multiple of 3,logCurrentPlayer()
will return undefined. maybe it is(currentTurn - 1) % players.length