Tell us what’s happening:
I tested the code but it is not working
Your code so far
var permArr = [],
usedChars = [];
function permute(input) {
var i, char;
for (i = 0; i < input.length; i++) {
char = input.splice(i, 1)[0];
usedChars.push(char);
if (input.length == 0) {
permArr.push(usedChars.slice());
}
permute(input);
input.splice(i, 0, char);
usedChars.pop();
}
return permArr;
};
function permAlone(str) {
var count = 0;
var repeat = false;
var splited = str.split('');
var permutations = permute(splited);
for(let i = 0; i<permutations.length; i++){
for(let j = 0; j<permutations[i].length; j++){
if(permutations[i][j]==permutations[i][j+1]){
repeat = true;
}
}
if(!repeat){
count++;
}
repeat = false;
}
return count;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge: