What is wrong with this code for Caesars Cipher? Why isn't it changed in arr3?

function rot13(str) {
  var arr3 = [];
  var arr = str.split(""); // LBH QVQ VG!
  var arr2 = [];
  for (var x = 0; x < arr.length; x ++){
  arr2.push(arr[x].charCodeAt(0));}
 

  for (var i = 0 ; i < arr2.length ; i ++) { 
   
  if (77 >= arr2[i] >= 65) {
       arr3.push(arr2[i] + 13);}
   else if (78 >= arr2[i] >= 90){
     arr3.push(arr2[i] - 13);}
    else arr3.push(arr2[i]);

  } 
return arr3;

}

I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

2 posts were split to a new topic: I do not see how knowing how to do something like this will help a person build a website

For one thing, to the best of my knowledge JS does not allow complex evaluations like this:

if (77 >= arr2[i] >= 65) {

You would need to break it into parts and use an and logical operator, like this:

if (arr2[i]<=77 && arr2[i]>=65) {

Thank you very much. I didn’t know that!