JSFiddle - React, Tailwind, and code Playground
by Alexander
JavaScript
console.clear();
function combos(list) {
const n = list.length;
let result = [];
for (let i = 0; i < n - 1; i++) {
for (let j = i + 1; j < n; j++) {
result.push([list[i], list[j]]);
}
}
return result;
}
console.log(combos(['a', 'b', 'c', 'd']));