Tell us what’s happening:
I want to swap the element of the str, then I want to get every combination by adding +1 to every index of every element. How can I do that. Your code so far
function permAlone(str) {
let splittedStr=str.split("")
let lengthOfSplittedStr=splittedStr.length;
let groupfGroups=[];
//console.log(lengthOfSplittedStr)
let factorial=1;
for(let i=1;i<=lengthOfSplittedStr;i++){
factorial*=i
}
for(let i =1;i<=factorial;i++){
groupfGroups.push(splittedStr.slice(i,i))
}
console.log(groupfGroups)
}
permAlone('ab');
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.86 Safari/537.36.