JSFiddle - React, Tailwind, and code Playground
JavaScript
function permutate_le_m(permutation) {
var length = permutation.length,
result = new Array([0, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600][length]),
c = new Array(length).fill(0),
i = 1,
j = 1;
result[0] = permutation.slice();
while (i < length) {
if (c[i] < i) {
var k = (i % 2) ? c[i] : 0,
p = permutation[i];
permutation[i] = permutation[k];
permutation[k] = p;
++c[i];
i = 1;
result[j] = permutation.slice();
++j;
} else {
c[i] = 0;
++i;
}
}
return result;
}
var people = ['bob', 'joe', 'jeff', 'sandy', 'jessica', 'april']
var shirts = ['red', 'blue', 'green', 'yellow', 'purple', 'white'];
var pshirts = permutate_le_m(shirts);
var combined = pshirts.map(perm=>perm.map((elem, ix)=>[people[ix], elem]));
console.log(combined);