JSFiddle - React, Tailwind, and code Playground
JavaScript
function pair(currentPlayer) {
let mainSet = [];
let subSet = [currentPlayer[0], currentPlayer[1], currentPlayer[2]];
for(let i = 0; i < currentPlayer.length - 2; i++) {
let arr = [];
for(let j = 3; j < currentPlayer.length; j++) {
let set = function() {
return currentPlayer[j];
}
arr[i] = set();
mainSet.push(subSet);
}
}
return mainSet;
}
console.log(pair([0, 2, 5, 7, 8]));