DEV Community

Discussion on: Caesar's Cipher (FreeCode Camp Solution)

Collapse
 
lexlohr profile image
Alex Lohr • Edited

If you are already using a for-loop instead of string.replace to iterate over the string, you can also use str.charCodeAt(i), so you don't have to convert the string to array first.

Then, you can use const inside the for loop instead of let outside. If you don't plan to replace the array, you can and should directly assign it (though it's not necessary).

Other than that, check my comment to Chris' post. ASCII characters are organized in a useful manner, something you can use.

Collapse
 
kirankamath96 profile image
Kiran Kamath

Thanks Alex . I will try that