For starters, the first test case of rot13("SERR PBQR PNZC") returns 'FEEE PODR CAMC' instead of FREE CODE CAMP. Put some console.log statements in your code to see what values certain variables have and you should see what the problem is.
function rot13(str) { // LBH QVQ VG!
let ab=['A','B','C','D','E','F','G','H','I','J','K','L','M'];let no=['N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
let ar = str.split('');
for(let i=0;i<ar.length;i++){if(ab.indexOf(ar[i])!==-1){let x=ab.indexOf(ar[i]);ar.splice(i,1,no[x]);}
else if(no.indexOf(ar[i])!==-1){let x=no.indexOf(ar[i]);
ar.splice(i,1,ab[x]);
}
}
return ar.join('');
}
Unhappyly it took me too much time. That’s why I don’t think there is some kind of ‘‘spoilers’’ right there. I’d rather call them ‘‘time savers’’ or just ‘‘helpers’’ because starters like me get stuck too much and that is very discouraging. Skipping challenges is heartbreaking. ‘‘spoilers’’ hold our hands when we lose faith.
Thanks again