Caesars Cipher Help Help

I am about halfway through with the Casesar’s Cipher puzzle. The Algorithm is incomplete, so disregard the last line of code. What I am wondering is why my

for (var i = 0; i < newArray.length; i++) {
    
    unicodeArray.push(newArray[i].charCodeAt());
  }

block of code works (I understand I am somehow using a string method on an array)
but this next block of code doesn’t work although very similar.

for (var x = 0; x < minus13Array.length; x++) {
    newLetterArray.push(minus13Array[x].fromCharCode());
  }

I think I can figure the rest of it out if I can figure this one bit out.

Your code so far

function rot13(str) { // LBH QVQ VG!
 var newArray = str.split("");
  var newString = "";
  var unicodeArray = [];
  var minus13Array = [];
  var newLetterArray = [];
  for (var i = 0; i < newArray.length; i++) {
    
    unicodeArray.push(newArray[i].charCodeAt());
  }
  for (var j = 0; j < unicodeArray.length;j++) {
    minus13Array.push((unicodeArray[j] - 13));
  }
  for (var x = 0; x < minus13Array.length; x++) {
    newLetterArray.push(minus13Array[x].fromCharCode());
  }
  
  
  
    
    return newLetterArray;
  
 
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:54.0) Gecko/20100101 Firefox/54.0.1 Waterfox/54.0.1.

Link to the challenge:

Ahh. I think I understand. So this line of code

unicodeArray.push(newArray[i].charCodeAt());

only worked because by default without an argument, the method indexes at [0], and since [i] iterates only one character at a time, it’s length at all times could be said to be 1? If that is the case I see now why that worked and the second one did not.

This is what I have now. I know I’m doing something really dumb.

for (var x = 0; x < minus13Array.length; x++) {
   newLetterArray.push(minus13Array[x].charCodeAt(minus13Array)); 
  }

Trying to push into a new array. Since charCodeAt() needs indexes as arguments to run, I figured the fully popuated minus13Array would work. Keeps telling me that ‘TypeError: minus13Array.charCodeAt is not a function’.

I added that line in there, but it’s still saying that my code is not a function. I thought it would run the console code first because it came before it. here’s what I have: (also, i decided to try giving it integer arguments, an arbitrary index and length but that produced no change.)

for (var x = 0; x < minus13Array.length; x++) {
    
    console.log(minus13Array[x]);
    newLetterArray.push(minus13Array.fromCharCode(4,6));
  }