Caesars Cipher help me please

I don’t know what’s wrong with my code. Somehow that returns “THE QUICK BROWN DLOG JUMPEDL OVER THE AZQ FOX.”, but with HUGE spaces beetwen words.

function rot13(str) { 
  str = str.split('');
  var alp = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Q','Z'];
  
  var newStr = "";
  
  for (var i = 0; i < str.length; i++) {       
    for ( var a = 0; a < alp.length ;  a++) {
      
      if (str[i] == " ") {                   // If element is space
        
        newStr += " ";
        
      } else if ( str[i] == alp[a] ) {         // if element is less than 13
        
        if (a < 13) {
          newStr += alp[a+13];
        } else 
          newStr += alp[a-13];
      }
      
    }
    
  }
  return newStr;
}

Thank you, that helped.