Caesars Cipher, how to pass on special characters?

Caesars Cipher, how to pass on special characters?
0.0 0

#1

Tell us what’s happening:

can someone help me figure out how to pass on the special symbols.
everything works fine except the special characters.

Your code so far

function rot13(str) { // LBH QVQ VG!
  var arr=[];
 
  for(var i=0;i<str.length;i++){
    
   arr[i]= str.charCodeAt(i)+13; 
    
  if(arr[i]>90){
    arr[i]=arr[i]%91 +65;
  }
    
  arr[i]=String.fromCharCode(arr[i]);
    
  
  }
  str=arr.join('');
  
  
return str;
}

// Change the inputs below to test
rot13("SERR CVMMN!");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36.

Link to the challenge:


#2

In your for loop you have

    arr[i] = str.charCodeAt(i) + 13;

This line converts any character (letters or symbols) to ASCII code. You should only convert the characters which are the letters A-Z.