Caesars Cipher - Why isn't it working?

Tell us what’s happening:

Your code so far

function rot13(str) { // LBH QVQ VG!
  var codedLetter = "";
  var uncodedLetter = "";  
  var newString = "";
  for(var i=0;i < str.length;i++){
    if(str.indexOf(i) == ""){
      uncodedLetter = " ";
    }else{
      codedLetter = str.charCodeAt(i)-13;
      uncodedLetter = String.fromCharCode(codedLetter);
      //console.log(codedLetter,uncodedLetter,newString);
    }
      newString = newString + uncodedLetter;
    console.log(newString);  
    //return newString;
  }
return newString;
}
// 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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36```.

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