Trouble with Caesars Cipher specifically the fromCharCode() function

    function rot13(str) { // LBH QVQ VG!
  for(var i=0;i<str.length;i++){
      var letter=str.fromCharCode(str.charCodeAt(i)+13);
  return str;
}`Preformatted text`

`indent preformatted text by 4 spaces`

Hey guys I keep getting a type error saying fromCharCode() is not a function.
I don’t understand why.
I know that str.charCodeAt(i) returns the unicode value for a character in a string and the argument that fromCharCode() uses numbers and returns the characters corresponding to that value.

You get .fromCharCode() directly from the String object, not from any string value.

var letter = String.fromCharCode(...);
1 Like

wow I feel foolish now. Thank you.

This will help in solving your issue