Created
March 26, 2017 22:03
-
-
Save oliverjam/0f5c033188c19d183637b9289ca20805 to your computer and use it in GitHub Desktop.
null created by oliverjam - https://repl.it/GfI5/0
This file contains hidden or 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
| const str = "SERR PBQR PNZC"; | |
| function rot13(string) { | |
| return string.split('') | |
| .map(word => { | |
| return word.split('') | |
| .map(letter => { | |
| const letterCode = letter.charCodeAt(0); | |
| if (! (letterCode >= 65 && letterCode <= 90)) return letter; | |
| if (letterCode <= 77) return String.fromCharCode(letterCode + 13); | |
| if (letterCode >= 78) return String.fromCharCode(letterCode - 13); | |
| }).join(''); | |
| }).join(''); | |
| } | |
| rot13(str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment