Caesars Cipher. if statements and regular expressions, help

Tell us what’s happening:
Hey, i got a problem to push spaces and non letter character into my resultArr. I tried to do this with regular expressions and if statements but it doesnt work, can someone hint me into a solution to this problem?

Your code so far


function rot13(str) { // LBH QVQ VG!
var input = str.split("");
  var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var rot = "NOPQRSTUVWXYZABCDEFGHIJKLM";
  var alphabetArr = alphabet.split("");
  var rotArr = rot.split("");
  var resultArr = [];
  var result;
 

  for (var i = 0; i < input.length; i++) {    
    for (var j = 0; j < rot.length; j++) {
      if (input[i] === rotArr[j]) {
        resultArr.push(alphabetArr[j]);
      } 
    }
   
  }
  console.log(resultArr);
  result = resultArr.join("");
  console.log(result);      // Returns FREECODECAMP without spaces :(
  
  
}

// Change the inputs below to test
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/70.0.3538.110 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/caesars-cipher/

Instead of having nested for loops, you should look at indexOf. Not only would this save you some looping, but it would also tell you if a character is not a letter.