Created
April 2, 2019 16:12
-
-
Save bmansk8/f91fdef757876fc1336d0d157825b915 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! | |
var codeArr = str.split(""); | |
var decodedArr=[]; | |
var alphabet=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M"]; | |
for(var i=0;i<codeArr.length;i++){ | |
if(alphabet.indexOf(codeArr[i])===-1){ | |
decodedArr.push(codeArr[i]); | |
}else{ | |
for(var j=0;j<alphabet.length;j++){ | |
if(codeArr[i]===alphabet[j]){ | |
decodedArr.push(alphabet[j+13]); | |
} | |
} | |
} | |
} | |
return decodedArr.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