Tell us what’s happening:
Where am I wrong in my code ? I thought I got it right ?
Is it due to the fact I only coded the matching for each character, instead of creating a processing algorithm ?
**Your code so far**
const rotted = {"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", "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", " " : " ", "." : ".", "!" : "!", "?" : "?"}
const newStr = []
function rot13(str) {
for (var i = 0; i < str.length; i++) {
if (rotted.hasOwnProperty(str[i])) {
newStr.push(rotted[str[i]])
}
}
const reunited = newStr.join('')
return reunited
}
rot13("SERR PBQR PNZC");
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36
Challenge: Caesars Cipher
Link to the challenge: