8000 Update caesar.js · GeraldCO/javascript-exercises@bde09da · GitHub
[go: up one dir, main page]

Skip to content

Commit bde09da

Browse files
authored
Update caesar.js
1 parent 8eeb98e commit bde09da

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

caesar/caesar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const caesar = function(string, shift) {
77

88
const codeSet = code => (code < 97 ? 65 : 97);
99

10+
# this function is just a fancy way of doing % so that it works with negative numbers
11+
# see this link for details:
12+
# https://stackoverflow.com/questions/4467539/javascript-modulo-gives-a-negative-result-for-negative-numbers
1013
const mod = (n, m) => (n % m + m) % m;
1114

1215
const shiftChar = (char, shift) => {

0 commit comments

Comments
 (0)
0