Welcome to the Caesar Cipher Challenge! In this mission, your robot's navigation system has been encrypted. You need to decode the commands to get the robot to the target. The target however has been hidden, so you can't see it yet.
Your goal is to write a function that decrypts a list of commands encrypted with a ROT13 cipher (a Caesar cipher with a shift of 13) and executes them. The robot must collect the gem to win.
How to win?
PICKUP the gem."SBEJNEQ", "YRSG", etc.A becomes N, B becomes O, ..., N becomes A.Z is followed by A.await robot.executePath(translatedCommands).await robot.pickup()."SBEJNEQ" -> "FORWARD""YRSG" -> "LEFT""EVTUG" -> "RIGHT"ROT13 ("rotate by 13 places") is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the alphabet. Because the basic Latin alphabet has 26 letters, applying ROT13 twice restores the original text.
You can use ASCII character codes to help with the shift.
String.fromCharCode(code) creates a character from a code.'A'.charCodeAt(0) gives you the code for 'A' (65).The modulo operator is very useful for wrapping around the alphabet.
index = (index + 13) % 26
const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
function translate(command: string) {
// Your implementation here
}