We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5db921c commit 5d5527cCopy full SHA for 5d5527c
2 files changed
algorithm/cryptography/caesar_cipher/basic/code.js
@@ -23,7 +23,7 @@ function cipher(str, rotation, direction, cipherTracer) {
23
cipherTracer._wait();
24
25
var currChar = str.charAt(i);
26
- if ( currChar !== ' ' ) { // do not encrpt/decrypt spaces
+ if (typeof alphabetMap[currChar] === 'number') { // don't encrpt/decrypt characters not in alphabetMap
27
var r = rotation;
28
29
logger._print('Rotating ' + currChar + ' ' + direction + ' ' + rotation + ' times');
@@ -35,7 +35,7 @@ function cipher(str, rotation, direction, cipherTracer) {
35
cipherTracer._notify(i, currChar)._wait();
36
}
37
} else {
38
- logger._print('Ignore space');
+ logger._print('Ignore this character');
39
40
str = str.substring(0, i) + currChar + str.substring(i + 1);
41
logger._print('Current result: ' + str);
algorithm/cryptography/caesar_cipher/basic/data.js
@@ -1,4 +1,4 @@
1
-var string = 'secret msg';
+var string = 'hello! how are you doing?';
2
var rotation = 5;
3
var alphabet = 'abcdefghijklmnopqrstuvwxyz';
4
// create a map of char -> position to improve run time
0 commit comments