After providing the input of 85 to this function, I noticed that it only returns 85. I am confused as to why it is not recursively calling itself again with 5 as the first number.
console.log(PermutationStep(85));
function PermutationStep(num) {
var permutations = [];
recursive(String(num), String(num).length, [], '');
return permutations;
function recursive(num, numLength, used, currentPermutation) {
console.log(currentPermutation);
if (currentPermutation.length === numLength) {
permutations.push(num);
}
for (var j=0; j<numLength; j++) {
if (used[j]) continue;
else {
used[j]=true;
recursive(num, numLength, used, currentPermutation+num[j]);
}
}
}
}