Skip to content

Instantly share code, notes, and snippets.

@James1x0
Created April 22, 2022 18:24
Show Gist options
  • Select an option

  • Save James1x0/2a06e718c86263c9a7dc12ccc98fd39e to your computer and use it in GitHub Desktop.

Select an option

Save James1x0/2a06e718c86263c9a7dc12ccc98fd39e to your computer and use it in GitHub Desktop.

Revisions

  1. James1x0 created this gist Apr 22, 2022.
    21 changes: 21 additions & 0 deletions unokata.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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();