Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
map solution in Clear category for [old] Caesar Cipher (encryptor) by Sim0000
"use strict";
function toEncrypt(text, delta) {
let f = c => /[a-z]/.test(c) ? String.fromCharCode((c.charCodeAt() + delta + 7) % 26 + 97) : c;
return text.split("").map(f).join("");
}
var assert = require('assert');
if (!global.is_checking) {
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(toEncrypt("a b c", 3), "d e f")
assert.equal(toEncrypt("a b c", -3), "x y z")
assert.equal(toEncrypt("simple text", 16), "iycfbu junj")
assert.equal(toEncrypt("important text", 10), "swzybdkxd dohd")
assert.equal(toEncrypt("state secret", -13), "fgngr frperg")
console.log("Coding complete? Click 'Check' to earn cool rewards!");
}
March 10, 2018
Comments: