const input = "zj4zcg5shsz";
const letters = input.split("");
const permCount = 1 << input.length;
const result = new Set()
for (let perm = 0; perm < permCount; perm++) {
// Update the capitalization depending on the current permutation
letters.reduce((perm, letter, i) => {
letters[i] = (perm & 1) ? letter.toUpperCase() : letter.toLowerCase();
return perm >> 1;
}, perm);
result.add(letters.join(""));
}