function rot13(str) {
var obj ={"N": "A" ,"O":"B","P":"C","Q":"D","R":"E","S":"F","T":"G","U":"H","V":"I","W":"J","X":"K","Y":"L","Z":"M" }
var obj2 ={ "A":"N" ,"B":"O","C":"P","D":"Q","E":"R","F":"S","G":"T","H":"U","I":"V","J":"W","K":"X","L":"Y","M":"Z","!":"!",".":".","?":"?" }
// ABCDEFGHIJKLM
// NOPQRSTUVWXYZ
var str2=''
for (var i =0; i<=str.length;i++){
str2+=obj[str[i]]===undefined?obj2[str[i]]:obj[str[i]];
}
console.log(str2.replace(/undefined/g," "),str)
return str2.replace(/undefined/g," ")
}
rot13("SERR PBQR PNZC");
So when i console this the outputs seem fine in console and it converts all cipher into translated english but the issue is the challenge is not completed
I would strongly recommend reworking your solution to avoid creating ‘undefined’ anywhere in your logic. That is an indication that something is going wrong.