Caesars Cipher need help with my code

Caesars Cipher need help with my code
0

#1

Below is my code.i can’t figure out what is wrong here…


function rot13(str) { // LBH QVQ VG!

let arr=[];

let stringval=[];

for(let i=0;i<str.length;i++){

if(str[i]!=' '){

if(str.charCodeAt(i)>=65&&str.charCodeAt(i)<=90){

let c=str.charCodeAt(i)-13;

arr[i]=String.fromCharCode(c);

if(c<65){

let d=arr[i]+13;

arr[i]=String.fromCharCode(d)

}

}}

else if(str[i]==" "){

arr[i]=' ';

}

}

return arr.join('');

}

#2

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate 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.

Note: Backticks are not single quotes.


#3

Have you been able to work this out? Otherwise I can take a look in a few hours