Caesars Cipher, why don't you want me?

Caesars Cipher, why don't you want me?
0.0 0

#1

Tell us what’s happening:

Hi everyone,
I’m trying to wrap up the cipher problem.
As far as I’m concerned my solution does work, but isn’t validated by the site.
At first I thought that quotes must be returned as part of the answer,
So I tried that, to no avail.
I get all the right results but for some reason my solution does not pass validation
I also didn’t use ES6 and cannot see any syntax errors. :thinking:
Can someone help?? thank you so much

Your code so far

["A","N"],
["B","O"],
["C","P"],
["D","Q"],
["E","R"],
["F","S"],
["G","T"],
["H","U"],
["I","V"],
["J","W"],
["K","X"],
["L","Y"],
["M","Z"],
["N","A"],
["O","B"],
["P","C"],
["Q","D"],
["R","E"],
["S","F"],
["T","G"],
["U","H"],
["V","I"],
["W","J"],
["X","K"],
["Y","L"],
["Z","M"]
];

var result = [];
function rot13(str){
  var allCaps = str.toUpperCase();
  allCaps = allCaps.split('');
  var l = allCaps.length;

  for(var i = 0; i < l; i++){
    if (allCaps[i].match(/[A-Z]/) !== null){
      for(var j = 0; j < paires.length; j++){
          if(allCaps[i] == paires[j][0]){
          result.push( paires[j][1]);
        }
      }
    }else{
      result.push(allCaps[i]);
    }    
  }
  var resultat = "\"" + result.join('') + "\"";
  return  resultat;
}
rot13("SERR YBIR?");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0.

Link to the challenge:


#2

Your code contains global variables that are changed each time the function is run. This means that after each test completes, subsequent tests start with the new value. To fix this, make sure your function doesn’t change any global variables, and declare/assign variables within the function if they need to be changed.

Example:

var myGlobal = [1];
function returnGlobal(arg) {
  myGlobal.push(arg);
  return myGlobal;
} // unreliable - array gets longer each time the function is run

function returnLocal(arg) {
  var myLocal = [1];
  myLocal.push(arg);
  return myLocal;
} // reliable - always returns an array of length 2