Caesars Cipher Better Solution Request

Caesars Cipher Better Solution Request
0.0 0

#1

Here is my solution but I felt like I cheated to quickly ignore the special characters.
Please give me some advise on how to improve my solution and write better code.
What I gone through was reading the methods (charCodeAt() &fromCharCode()) then though about what I learned from previous lessons to find a solution.
I thought I should turn the Characters into uni-code(numbers) then turn them back to Characters after I add 13 to each one of them since the rule of CC was to shift 13 places for each of the alphabets.
First Problem I encountered was to figure out the actual numerical equivalent of the alphabets.
After that I realize I can’t simply shift alphabets by adding so I hard coded stuff to find where to subtract 13 to get the right uni-code number.
Finally I got it but I felt like I am not thinking like a good programmer.
Please throw anything at me which you consider good practice in approaching problems such as this one.

Thank you


#2

Instead of checking for specific special characters, you could check if each character is within the alphabet range. That way, everything that’s not a letter is unaffected by the cypher, and you don’t need to worry about every special character.

Also, this is a nitpick, but you can reuse i for each for statement; it is only nested for statements that need different variable names.