Caesars Challenge- Why it doesn't pass? [SOLVED]

Caesars Challenge- Why it doesn't pass? [SOLVED]
0.0 0

#1

Hello I worked for days with this challenge, but I believe I got it solved.
The code passes on the other console environments like repl.it but not to freecodecamp. Could any one review why it doesn’t pass please?

function rot13(str) {
  var decodedPhrase = [];
  //transform string into uppercase and remove spaces and special characters
  var wordExpression = str.replace(/^[a-zA-Z]*$/g).toUpperCase();
  //From str value or wordExpression get the Unicode value of each letter
  for (var i = 0; i < wordExpression.length; i++) {
    //Get the values from N to Z substracting 13 to get the same result values of A to M
    if (wordExpression.charCodeAt(i) >= 78 && wordExpression.charCodeAt(i) <= 90) {
      var secondValues=wordExpression.charCodeAt(i) - 13;
      decodedPhrase.push(secondValues);
      
      //Get the A to M values backward
    } else if(wordExpression.charCodeAt(i) >= 65 && wordExpression.charCodeAt(i) <= 77){
        var firstValues=wordExpression.charCodeAt(i)+13;
        decodedPhrase.push(firstValues);
      } else if(wordExpression.charCodeAt(i) < 65 || wordExpression.charCodeAt(i) > 90) {//Get the unicode special characters value
        
        var otherValues=wordExpression.charCodeAt(i);
        decodedPhrase.push(otherValues);
        }
    
    var res=String.fromCharCode(...decodedPhrase).split("").join(" ");
    
  } 
  
  return res;
}


#2

There shouldn’t be spaces between the letters in a word


#3

Thank you. I didn’t realize that the results in the console were spaces in between.

Thank you a lot!