JavaScript - Seperate array into an array of pairs
<p>I have an array of team names which is like this:</p>

<p><code>teams = ['team1', 'team2', 'team3', 'team4']</code></p>

<p>I want to create a set of matches based on this, so at the moment, for a set of matches using the teams array you would get:</p>

<pre><code>teamMatches : [
  [ teams[0],  teams[1] ],
  [ teams[2],  teams[3] ]
]
</code></pre>

<p>My question is, can anyone think of a way to produce this teamMatches array based upon a teams array with length <code>n</code>. The teams array will always be a correct number, 4,8,16 etc. I have tried using <code>Math.pow</code> with 2 to try to produce the brackets with no success.</p>

<p>Any ideas?</p>
