set05

Build every gift-pair combination

5 / 26
read the snippet · pick its Big-O
// Matches each customer with every other customer for a "Secret Santa" UI preview.
function allPairs(users) {
const pairs = [];
for (let i = 0; i < users.length; i++) {
for (let j = 0; j < users.length; j++) {
if (i !== j) pairs.push([users[i], users[j]]);
}
}
return pairs;
}