Tell us what’s happening:
ok i think i have almost solved the problem…
but there is a little bug…which is “-” appearing on the blank strings…as you can see it in the output.
so how can i remove it and have “space” instead.
Your code so far
function rot13(str) { // LBH QVQ VG!
var arr = [];
var fixed = [];
var final = [];
var result = "";
for(i = 0; i<str.length; i++){
arr.push(str.charCodeAt(i));
}
arr.map(function(val){
fixed.push(val + 13);
});
for (j = 0; j<fixed.length; j++){
if (fixed[j] > 90){
final.push((fixed[j]-90)+64);
}
else{
final.push(fixed[j]);
}
}
result += String.fromCharCode.apply(null, final);
return result;
}
//OUTPUT--> FREE-CODE-CAMP
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
.
Link to the challenge: