I made my Caesar Cipher project and it’s working completely fine, doing what it is supposed to, even though the FCC algorithm doesn’t approve it. Is there something wrong with the code, the input or it’s just an intern error of fcc?
**My code so far**
function rot13(str) {
let newStr = []
str.split('').map(char => {
let newChar = undefined
if (/\W/g.test(char) || /\d/g.test(char)) {
newStr.push(char)
} else if (/([A-Z])/g.test(char)) {
newChar = (((char.charCodeAt(0) - 'A'.charCodeAt(0)) + 13) % 26) + 'A'.charCodeAt(0)
} else if (/([A-Z])/g.test(char)) {
newChar = (((char.charCodeAt(0) - 'a'.charCodeAt(0)) + 13) % 26) + 'a'.charCodeAt(0)
} else {newStr.push(char)}
newStr.push(String.fromCharCode(newChar))
})
return newStr.join('');
}
console.log(rot13("SERR YBIR?"))
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Challenge: Caesars Cipher
Link to the challenge: