Caesars Cipher -Solved

Caesars Cipher -Solved
0.0 0

#1

Can we solve the same in another way?


#2

Try it and find out! Get used to exploring ideas in code rather than being told what you can and cannot do.


#3
function rot13(str){
     wordA = 'A'.charCodeAt(0);
     wordN = 'N'.charCodeAt(0);
     wordZ = 'Z'.charCodeAt(0);
freshArr = [];
 
for (var i = 0;i<str.length;i++) {
    var word = str.charCodeAt(i);
    if(word >=wordN){
     freshArr.push(String.fromCharCode(word-13))
    }
    else{
        freshArr.push(String.fromCharCode(word+13));
    }
}
return freshArr.join("");
    }
    console.log(rot13('SERR PBQR'));
    ```

Iā€™m almost done with this but my O/P has a ā€œ-ā€ in between.