Caesars Cipher ("-" between spaces)

Tell us what’s happening:
ok i think i have almost solved the problem…
but there is a little bug…which is “-” appearing on the blank strings…as you can see it in the output.
so how can i remove it and have “space” instead.

Your code so far

function rot13(str) { // LBH QVQ VG!
  
  var arr = [];
  var fixed = [];
  var final = [];
  var result = "";
  
  for(i = 0; i<str.length; i++){
    arr.push(str.charCodeAt(i));
  }
  
arr.map(function(val){
    fixed.push(val + 13);
 });

  for (j = 0; j<fixed.length; j++){
    if (fixed[j] > 90){
      final.push((fixed[j]-90)+64);
    }
    else{
      final.push(fixed[j]);
    }
  }

result += String.fromCharCode.apply(null, final);

  return result;
}

//OUTPUT--> FREE-CODE-CAMP

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

Your browser information:

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

Link to the challenge:

How can you change your logic so that it only changes the values of characters that are letters?

i was thinking about filter() …but not sure how to use it

filter is generally going to be used to remove values from the array. What you want is for the character codes for non-letters to go into your fixed array without being changed (without adding 13) or for those to be changed back to their original values in your for loop (less efficient of course, but perhaps easier for you since you already have some logic like this).

not happening … a little help here …perhaps

Well, what have you tried since changing your code to the above? What worked? What didn’t? What behaved differently than expected?