title: Rock Paper Scissors Recursion
body: <pre><code>var rockPaperScissors = function(rounds) {
    var outcomes = [];
    var plays = ['rock', 'paper', 'scissors'];
    var playedSoFar = [];
  
    var combos = function(roundsToGo) {
      // base case
      if (roundsToGo === 0) {
        outcomes.push(playedSoFar.slice());
        return;
      }
  
      for (var i = 0; i &lt; plays.length; i++) {
        playedSoFar.push(plays[i]);
        combos(roundsToGo - 1);
        playedSoFar.pop();
      }
    };
    combos(rounds);
    return outcomes;
  };
  
  console.log(rockPaperScissors(2));
  </code></pre>
  
  <p>If I take out the <code>slice()</code> from the <code>playedSoFar</code>, <code>outcomes</code> just gets returned as nine empty arrays, instead of all the combinations from a 2 round rock paper scissors game:</p>
  
  <pre><code>[ [ 'rock', 'rock' ],
    [ 'rock', 'paper' ],
    [ 'rock', 'scissors' ],
    [ 'paper', 'rock' ],
    [ 'paper', 'paper' ],
    [ 'paper', 'scissors' ],
    [ 'scissors', 'rock' ],
    [ 'scissors', 'paper' ],
    [ 'scissors', 'scissors' ] ]
  </code></pre>
  
  <p>Why doesn't this work when I take out the <code>slice()</code> from the <code>playedSoFar</code>?</p>