JavaScript Algorithms and Data Structures Projects - Caesars Cipher

Tell us what’s happening:
Describe your issue in detail here.
If I print ‘arr’ before it’s return statement, the code works completely fine and all the results match (I gave all possible inputs to cross-check and the result is right every time). Though it doesn’t run like this. Can someone help me out please?

Your code so far

function rot13(str) {
  var str1=str.split(" ");
  var arr="";
  for(let i in str1)
    for(let j in str1[i])
    var integer=str1[i].charCodeAt(j);
    if(integer>=65 && integer<78) integer+=13;
    else if(integer==33||integer==44||integer==46||integer==47) integer=integer;
    else integer-=13;
    arr=arr+" ";
   return arr;

rot13("SERR PBQR PNZC");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/114.0.1823.67

Challenge: JavaScript Algorithms and Data Structures Projects - Caesars Cipher

Link to the challenge:

‘arr’ isn’t really an array. I’d change that name.

Also, you shouldn’t be using var.

Your answer needs to have only spaces in the places the original string had spaces.

You need to remove extra white space at the end of sentence.

Yes that’s is how it’s does and I’ve done everything but it still not going

You fixed your extra space? Please show your new code.

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