Tell us what’s happening:
Hi all!
This is my first post here so cut me some slack if my code sucks.
For some reason, the code works well when I run it on visual studio, I pass all the tests. When I run the code on the website, it says it sucks:(
Why does my code not work on the website?!!?!
Your code so far
var ans='';
var d='';
var charFromString="";
var charFromStringCode="";
var ModcharFromStringCode="";
var ModcharFromString_String="";
function rot13(str) {
// get char values from input
var len = str.length;
for (i = 0; len-1>= i; i++) {
charFromString = str[i];
charFromStringCode = str[i].charCodeAt(0);
if( charFromStringCode>77 && charFromStringCode<=90 ) {
ModcharFromStringCode=charFromStringCode-13;
}
else if( (65 <= charFromStringCode) && (charFromStringCode<=77) ) {
ModcharFromStringCode = charFromStringCode+13;
}
else {ModcharFromStringCode=charFromStringCode;}
ModcharFromString_String= String.fromCharCode(ModcharFromStringCode);
ans+=ModcharFromString_String;
}
return ans;
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36
.
Challenge: Caesars Cipher
Link to the challenge: