Last active
May 24, 2017 04:21
-
-
Save jsjoeio/0e69578613af371cb408d491b35b7ef3 to your computer and use it in GitHub Desktop.
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
function rot13(str) { // LBH QVQ VG! | |
debugger; | |
var newArr = []; | |
for(var i = 0; i < str.length; i++){ | |
var letter = str.charCodeAt(i); | |
if (64 < letter && letter < 78){ | |
newArr.push(String.fromCharCode(letter+13)); | |
} | |
else if(77 < letter && letter < 91){ | |
newArr.push(String.fromCharCode(letter-13)); | |
} else { | |
newArr.push(String.fromCharCode(letter)); | |
} | |
} | |
return newArr.join(""); | |
} | |
// Change the inputs below to test | |
rot13("SERR PBQR PNZC"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment