Skip to content

Instantly share code, notes, and snippets.

@Dylan-Thomson
Created June 5, 2017 15:23
Show Gist options
  • Select an option

  • Save Dylan-Thomson/11f66dc83f8dea81f55eb2214d835a9b to your computer and use it in GitHub Desktop.

Select an option

Save Dylan-Thomson/11f66dc83f8dea81f55eb2214d835a9b to your computer and use it in GitHub Desktop.
FreeCodeCamp ROT13 Solution
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