Code below will hang the app when the for loop attempts to equate i < loop (the second for loop). Changing length to a number or not using it in the loop will prevent the hang.
I’ve tested in both firefox and chrome with the same result.
Codepen app (link) using the same code does not appear to have any issues.
Any help/insight would be appreciated.
function permAlone(str) {
var length = str.length;
//return length;
var perm = 1;
for (var i = 2; i <= length; i++) {
perm *= i;
}
//return length*perm;
var loop = length*perm;
loop = loop.toString();
loop = Number(loop);
//return loop;
var permArr = [];
for (i = 0; i < loop; i++) {
permArr[i] = i;
}
return permArr;
return str;
}
permAlone('aab');