Created
June 5, 2017 15:23
-
-
Save Dylan-Thomson/11f66dc83f8dea81f55eb2214d835a9b to your computer and use it in GitHub Desktop.
FreeCodeCamp ROT13 Solution
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
| function rot13(str) { | |
| return str.split('').map(function(char) { | |
| var charCode = char.charCodeAt(); | |
| if(charCode >= 65 && charCode <= 90) { | |
| charCode = (charCode - 65 + 13) % 26 + 65; | |
| } | |
| return String.fromCharCode(charCode); | |
| }).join(''); | |
| } | |
| rot13("SERR PBQR PNZC"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment