Null Value returned

I am doing the Caesars Cipher challenge.
I believe my code should be working but I am getting an error I don’t understand. I get 12 red dots.

Here is my code

function rot13(str) { 
 //str = str.split('');
 var arr = [];
 // var regex = /[^a-zA-Z]/g;
  for (var i = 0; i < str.length; i++){
    if (str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
      arr.push(String.fromCharCode(str.charCodeAt[i] += 13));
      }else if(str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90){
      arr.push(String.fromCharCode(str.charCodeAt[i] -= 13));
      }else if (str.charCodeAt(i) < 65){
        arr.push(str[i]);
        }
  }
  
  return arr.join('');
}
rot13("SERR PBQR PNZC");

The following line has two errors.

arr.push(String.fromCharCode(str.charCodeAt[i] += 13));
  1. You can not use += unless you are assigning something a value. You just need + without the =.

  2. charCodeAt is a function. To call a function, you must use the syntax functionName(parameter) not functionName[parameter]

The following line has two similar errors:

arr.push(String.fromCharCode(str.charCodeAt[i] -= 13));

Fix these two lines above and your solution will work.

1 Like

Thank you very much. I can’t believe that this was the simple error I overlooked.