JavaScript Algorithms and Data Structures Projects - Caesars Cipher

Tell us what’s happening:
Describe your issue in detail here.

Why isn’t this working?!!!

Your code so far

function rot13(str) {
   let alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
   let arr = str.toUpperCase().split("")

   
   for(let letter = 0; letter < arr.length; letter++){
     if(alphabet.indexOf(arr[letter]) >= 0){
       arr[letter] = alphabet[letter + 13]
     }
   }

   return arr.join("")
}

console.log(rot13("a"));

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36

Challenge: JavaScript Algorithms and Data Structures Projects - Caesars Cipher

Link to the challenge:

Look at a more complete test case:

console.log(rot13("abcdefghijklmnopqrstuvwxyz"));
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.