Created
December 16, 2014 21:36
-
-
Save dewey/341585f0a27178a20502 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = ['p1', 'p2', 'p3', 'p4', 'p5', 'p6'] | |
var output = []; | |
var counter = 0; | |
for(var i = 0; i <= input.length-1; i++) { | |
var tupel = []; | |
if(counter == 0) { | |
tupel.push(input[i]) | |
counter++; | |
} | |
if(i == (counter - 1)) { | |
tupel.push(input[i+1]) | |
output.push(tupel) | |
} | |
if(counter < i) { | |
tupel = []; | |
tupel.push(input[counter]) | |
tupel.push(input[i]) | |
output.push(tupel) | |
counter++; | |
} | |
} | |
console.log(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment