Advertisement
cecko

Untitled

Mar 12th, 2023
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. function theImitationGame(input) {
  2.  
  3. let encryptedMessage = input.shift();
  4.  
  5. for (let line of input) {
  6. let tokens = line.split("|");
  7. let command = tokens.shift()
  8. let index1 = tokens[0];
  9. let index2 = tokens[1];
  10. while (command !== "Decode") {
  11. if (command === "ChangeAll") {
  12. while (encryptedMessage.includes(index1)) {
  13. encryptedMessage = encryptedMessage.replace(index1, index2);
  14. }
  15.  
  16. } else if (command === "Insert") {
  17. encryptedMessage = encryptedMessage.concat(index1, index2);
  18. }
  19. }
  20.  
  21.  
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement