Caesars Cipher Challenge

Tell us what’s happening:
Hi everyone,

So far I could get the decrypted strings, but I am not able to process only letters from A-Z and leave all the rest untouched. To be honnest, I have a problem with regular expressions.

Could anyone help me??

Your code so far

function rot13(str) { // LBH QVQ VG!
  var rotate13 = [];
  var i;
  var res;
  var replaced;
  
  for (i = 0; i < str.length; i++) {
    if (str.charCodeAt(i) + 13 > 90) {
      rotate13.push(String.fromCharCode(64 + str.charCodeAt(i) - 90 + 13));
    } else {
      rotate13.push(String.fromCharCode(str.charCodeAt(i) + 13));
    }
    res = rotate13.join("");
    replaced = res.replace(/-/g, " ");
  }
  return replaced;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0.

Link to the challenge:
https://www.freecodecamp.org/challenges/caesars-cipher