Created
June 15, 2016 07:31
-
-
Save yarkovaleksei/2d70f03e74f167fd4619b6743ddc3cb9 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 str = "My top secret phrase!" | |
String.prototype.rot13 = function(){ | |
return this.replace(/[a-zA-Z]/g, function(c){ | |
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26); | |
}); | |
}; | |
alert(str.rot13()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment