javascript find pairs in array code example
Example: every possible pairing in an array javascript in new array
function pairs(arr) {
var res = [],
l = arr.length;
for(var i=0; i<l; ++i)
for(var j=i+1; j<l; ++j)
res.push([arr[i], arr[j]]);
return res;
}
pairs([1, 2, 3]).forEach(function(pair){
console.log(pair);
});