Hi,

I did not read all solution but as I seen everyone resolved this challenge with array.

My solution is working with string…

In guide topic the regEx code is really elegant,

```
var regex = /(.)\1+/;
```

unfortunately I did not find this easy code, my regex is more complex, but still works…

My solution:

```
function permAlone(str) {
if (str.length < 2) return str.length;
const uniqueArray = dirtyArray => dirtyArray.filter((value, index, array) => array.indexOf(value) === index);
const uniqueChars = uniqueArray([...str]);
const permFunc = (str) => {
// if (str.length < 2) return str;
const permutation = []; // This array will hold our permutations
for (let i = 0; i < str.length; i ++) {
const char = str[i];
const remainingString = str.slice(0, i) + str.slice(i + 1, str.length);
for (let subPermutation of permFunc(remainingString)) {
permutation.push(char + subPermutation);
}
}
return permutation;
}
let permutations = permFunc(str);
let regEx = new RegExp(`${uniqueChars.join("{2}|")}{2}`);
permutations = permutations.filter(value => !(regEx.test(value)));
return permutations.length;
}
```