I have an array of team names which is like this:
teams = ['team1', 'team2', 'team3', 'team4']
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:
teamMatches : [
[ teams[0], teams[1] ],
[ teams[2], teams[3] ]
]
My question is, can anyone think of a way to produce this teamMatches array based upon a teams array with length n. The teams array will always be a correct number, 4,8,16 etc. I have tried using Math.pow with 2 to try to produce the brackets with no success.
Any ideas?