remove timer and simon

This commit is contained in:
Cody Loyd
2017-12-15 12:56:14 -06:00
parent 14cc7d40bd
commit 834d78b8b2
2928 changed files with 303453 additions and 313 deletions
+21 -3
View File
@@ -1,5 +1,23 @@
var caesar = function() {
const caesar = function(string, shift) {
return string
.split("")
.map(char => shiftChar(char, shift))
.join("");
};
}
const codeSet = code => (code < 97 ? 65 : 97);
module.exports = caesar
const mod = (n, m) => (n % m + m) % m;
const shiftChar = (char, shift) => {
const code = char.charCodeAt();
if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122)) {
return String.fromCharCode(
mod(code + shift - codeSet(code), 26) + codeSet(code)
);
}
return char;
};
module.exports = caesar;