Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function theImitationGame(input) {
- let encryptedMessage = input.shift();
- for (let line of input) {
- let tokens = line.split("|");
- let command = tokens.shift()
- let index1 = tokens[0];
- let index2 = tokens[1];
- while (command !== "Decode") {
- if (command === "ChangeAll") {
- while (encryptedMessage.includes(index1)) {
- encryptedMessage = encryptedMessage.replace(index1, index2);
- }
- } else if (command === "Insert") {
- encryptedMessage = encryptedMessage.concat(index1, index2);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement