Last active
December 16, 2015 12:58
-
-
Save nickwaelkens/5438056 to your computer and use it in GitHub Desktop.
ROT13 in CoffeeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "stop, hammertime".rot13() // returns "fgbc, unzzregvzr" | |
# "fgbc, unzzregvzr".rot13() // returns "stop, hammertime" | |
String::rot13 = -> | |
this.replace /[a-zA-Z]/g, (c) -> | |
String.fromCharCode (if ((if c <= "Z" then 90 else 122)) >= (c = c.charCodeAt(0) + 13) then c else c - 26) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment