Caesars Cipher algorithm

Tell us what’s happening:
Hi Everyone,

I have been stuck on this for a while now. I am able to return the proper numbers but I cannot convert them back to letters. What am I doing wrong?

Thank you in Advance for your help!

Your code so far

function rot13(str) { // LBH QVQ VG!
  var result = [];

  for(var i = 0; i<str.length; i++){
    if(result[i] < 78 && result[i] > 64){
     result[i]+= 13;
    }else if(result[i] > 77 && result[i] < 91){

// 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/63.0.3239.132 Safari/537.36.

Link to the challenge:

From your code, result is an array with the correct ASCII codes. You have two issues with following line after your for loop

  1. You should be using a return statement (but you probably would have figured that out)

  2. You are trying to pass an array into the String.fromCharCode function. The function is expecting a single ASCII code. You will need to iterate your result and build a string containing each conversion of each number in the result array. Finally, you will return this string back to the calling function.