Skip to content

Instantly share code, notes, and snippets.

@James1x0
Created April 22, 2022 18:24
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 James1x0/2a06e718c86263c9a7dc12ccc98fd39e to your computer and use it in GitHub Desktop.
Save James1x0/2a06e718c86263c9a7dc12ccc98fd39e to your computer and use it in GitHub Desktop.
I play next on a reverse in uno, change my mind
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();
@johnkimz
Copy link

johnkimz commented Apr 22, 2022

bug in the code. whenever currentTurn is a multiple of 3, logCurrentPlayer() will return undefined. maybe it is (currentTurn - 1) % players.length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment