Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function rot13(str) {
- // LBH QVQ VG!
- var newString = '';
- function charVal(char) {
- if (char < 65) {
- return char;
- } else {
- return char % 26 + 65;
- }
- }
- for (var i = 0; i < str.length; i++) {
- var x = str.charCodeAt(i);
- newString += String.fromCharCode(charVal(x));
- }
- return newString;
- }
- // Change the inputs below to test
- //rot13("SERR PBQR PNZC")
- //rot13("SERR CVMMN!")
- //rot13("SERR YBIR?")
- //rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.")
- rot13('LBH QVQ VG!');
Add Comment
Please, Sign In to add comment