Caesar cipher
, also known as a shift cipher
. In a shift cipher
the meanings of the letters are shifted by some set amount.
A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.
Write a function which takes a ROT13 encoded string as input and returns a decoded string.
All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.
Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.
rot13("SERR PBQR PNZC")
should decode to FREE CODE CAMP
testString: assert(rot13("SERR PBQR PNZC") === "FREE CODE CAMP");
- text: rot13("SERR CVMMN!")
should decode to FREE PIZZA!
testString: assert(rot13("SERR CVMMN!") === "FREE PIZZA!");
- text: rot13("SERR YBIR?")
should decode to FREE LOVE?
testString: assert(rot13("SERR YBIR?") === "FREE LOVE?");
- text: rot13("GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.")
should decode to THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
testString: assert(rot13("GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.") === "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.");
```