Good day to all. Help please. This is one of the 5 project tasks. This is decoding using the Caesar cipher. At me all tests pass for all test data which are offered on a site freecodecamp. But on a site all tests are missing. Thanks
Caesars Cipher
function rot13(str) {
var alphabet = "abcdefghijklmnopqrstuvwxyz".toUpperCase()
var result = ''
for (const letterKey in str.toUpperCase()) {
let positionAlfa = -1//findAlphabetPosition(alphabet,str[letterKey])
for (const alphabetKey in alphabet) {
if (alphabet[alphabetKey] === str[letterKey]) {
positionAlfa = alphabetKey
break
}
}
if (positionAlfa === -1) {
result = result.concat(str[letterKey])
} else {
var decodeLetter = ''//decode(alphabet,positionAlfa)
let index = positionAlfa - 13 >= 0 ? positionAlfa - 13 : alphabet.length + (positionAlfa - 13)
decodeLetter = alphabet[index]
result = result.concat(decodeLetter)
}
}
console.log(result)
return str;
}
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/90.0.4430.93 Safari/537.36
.
Challenge: Caesars Cipher
Link to the challenge: