hello, I am trying to solve no repeats algorithm, my code is

```
function perMute(str){
let resultArr = [] // in this array we will save our combinations
str = str.split("");
//let count how many combination is possible(factorial of length)
let com = 1
let len = str.length;
for(let i =1;i<=len;i++){
com*=i
}
// looping and swaping
let places = len - 1;
let start = 0;
for(let i = 1;i<=com;i++){
swapme(str,start,start+1);
start++;
if(start === len-1){
start = 0;
} // reset the start value if it's same as str length
}
// make a swap function
function swapme(str,indexA,indexB){
let tmp = str[indexA];
str[indexA] = str[indexB];
str[indexB] = tmp;
// test the result and insert it
let testing = /(.)\1+/;
if(testing.test(resultArr[0])){
resultArr.shift();
}
if(!testing.test(str.join(""))){
resultArr.push(str.join(""));
}
}
return resultArr.length
}
```

for perMute(“abc”),perMute(“aab”) the result is correct

however it didn’t return correct result in perMute(“abcdefa”)

please someone tell what i did wrong in this code