You can get all combinations of the length of n
with this function:
function combinations(items, n) {
const result = [];
if (n === 1) return items.map(item => [item]);
for (let i = 0; i < items.length - n + 1; i++) {
result.push(
...combinations(items.slice(i + 1), n - 1).map(
t => [...items.slice(i, i + 1), ...t]
)
);
}
return result;
}
Then, you can get all possible combination simply with:
const groups = combinations(checkboxes, 6);