Caesars Cipher is throwing error though the output returned is correct

Caesars Cipher is throwing error though the output returned is correct
0.0 0

#1

Tell us what’s happening:

Your code so far

function rot13(str) { // LBH QVQ VG!
  var Arr = str.split(" ");
  //var ar = Arr[0].split('');
  var aa="\"";
  var a='';
  var Arre=[];
  for(var j=0;j<Arr.length;j++){    
  var ar = Arr[j].split('');   
  for(var i=0;i<ar.length;i++){   
    if(ar[i].charCodeAt() > 64 || ar[i].charCodeAt() > 97 && ar[i].charCodeAt() != 32){
      var bb = ar[i].charCodeAt();    
    if(bb>77){
      a = String.fromCharCode(bb -13);
    }else{
      a = String.fromCharCode(bb +13);
    }    
    Arre.push(a);      
    }else{
      Arre.push(ar[i]);
    }    
    }    
    Arre.push(" ");
  }
  aa = Arre.join('').trim();
  return "\""+aa+"\"";
}

// Change the inputs below to test
rot13("SERR CVMMN!");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

Link to the challenge:


#2

Hi @arun4aue

I’m not sure why you’re returning a string that’s wrapped in quotes, but if you remove them the challenge should pass.

return aa;

#3

Thanks a lot… it was helpful.