Can anyone help me with this Caesars Cipher?

function rot13(str) {

  let Arr1 = str.split('');
  let cCode = Arr1.charCodeAt(0);
  let result=[];
for(let i=0;i<cCode.length;i++){

  if(cCode[i]<65 || cCode[i]>90){
    result.push(fromCharcterCode(cCode[i]));
  }
  if(cCode<78){
    result.push(fromCharacterCode(cCode[i]+13));
  }
  else{
    result.push(fromCharacterCode(cCode[i]-13));
  }
}
return result.join('');
}

rot13("SERR PBQR PNZC");

I don’t think that this is actually an array.

It would help if you describe what you think that your code is doing.

1 Like

I thought characterCodeAt(0) going to convert all the array into Unicode, but it only converted the first index, thanks

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.