Created
August 19, 2018 20:40
-
-
Save cefaijustin/0d9eab9b7eb4d8a405ba43c1e0cde958 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
var alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXWZ"; | |
var cipher = "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXWZABCDEFGHIJKLM"; | |
function rot13(message){ | |
return message.split('').map(function(c) { | |
var i = alphabet.indexOf(c); | |
if (i < 0) { | |
// not in alphabet, return char | |
return c; | |
} | |
return cipher[i]; | |
}).join(''); | |
} | |
console.log(rot13("Yeah, it's hot outside too.")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment