Skip to content

Instantly share code, notes, and snippets.

@hikari-no-yume
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hikari-no-yume/53a7b6c1fee34b3dd496 to your computer and use it in GitHub Desktop.
Save hikari-no-yume/53a7b6c1fee34b3dd496 to your computer and use it in GitHub Desktop.
rot13 ES6
const rot13c = (c) =>
('a' <= c && c <= 'z') ? String.fromCharCode(97 + (c.charCodeAt(0) - 97 + 13) % 26) :
('A' <= c && c <= 'Z') ? String.fromCharCode(65 + (c.charCodeAt(0) - 65 + 13) % 26) :
c
const rot13 = (str) =>
Array.prototype.map.call(str, rot13c).join('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment