We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c376de5 commit c801b3eCopy full SHA for c801b3e
src/_Classics_/caeser_cipher/index.js
@@ -23,6 +23,10 @@ function caeserCipher(str, num) {
23
newIndex -= totalAlphabets;
24
}
25
26
+ if (newIndex < 0) {
27
+ newIndex = totalAlphabets + newIndex;
28
+ }
29
+
30
// check if the character in original string was upper case
31
if (str[index] === alphabets[currentIndex].toUpperCase()) {
32
result += alphabets[newIndex].toUpperCase();
0 commit comments