Caesars ciphers

Tell us what’s happening:
pourquoi ça ne marche pas

  **Your code so far**

function rot13(str) {
let alphabet = "ABCDEFGHIJKLMNNOPQRSTUVWXYZ";
let answer = ""
for(let i = 0; i < str.length; i++){
 if (alphabet.indexOf(str[i]) >= 13) {
   answer += alphabet[alphabet.indexOf(str[i]) -13]
 } else if (alphabet.indexOf(str[i]) < 13 && alphabet.indexOf(str[i]) > -1) {
   answer += alphabet[alphabet.indexOf(str[i])+13]
 } else {
   answer += str[i]
 }
 }
 

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/100.0.4896.75 Safari/537.36

Challenge: Caesars Cipher

Link to the challenge:

Have you logged the output? I see two issues.

  1. Where is your return statement?

  2. Are you covering all non-letter cases correctly?

1 Like

merci pour votre réaction à ma question
mais j’ai trouvé la solution