# Caesars Cipher- Code review

Tell us what’s happening:
Hi there!

As a continuation to learn, I hope you can assist me in debugging my code. I’ve read some notes elsewhere but am trying not to spoil solutions. I’m sure this isn’t the most effective solution, but it was what I started with and if not right route, point how I can make it better!

Thank you
PSEUDO:

1. Define variables.
2. Recognize alphabet ASCII is between 65->90, need to pass special characters (value outside this range)
3. Create a for loop based on the function length
4. Nest if statement. The ifstatement uses str.CharCodeAt to add 13 to each value and assign it to an array. Place an else statement to return the original value if outside 65-90 value
5. Nest another if statement to subtract 26 if larger than 90
6. Use join to convert the array to str
7. Convert the numbers back to a string
8. Return final str

Issues:
a) The characters are still recognized as between 65-90 and have 13 added to them
b) The Str.fromCharCode isnt converting it.

``````function rot13(str) { // LBH QVQ VG!
var arr =[];
var num = 0;
var newstr="";
var finalstr = "";

for (i = 0;i<str.length;i++){
if (str.charCodeAt(i)>=65 && str.charCodeAt(i)<=90){

arr[i] = str.charCodeAt(i)+13;
if(arr[i]>90){
arr[i]=arr[i]-26;
}
}
else{
arr[i]=str.charCodeAt(i);
}
}

newstr=arr.join();

String.fromCharCode(newstr);

return newstr;
}

// Change the inputs below to test
rot13("SERR CVMMN!");
``````

Your Browser User Agent is: `Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0`.