Guest User

Untitled

a guest
Apr 13th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function deciphering(inputArea) {
  2.     let stringToDecript = inputArea[0];
  3.     let wordsToReplace = inputArea[1].split(' ');
  4.     let pattern = /[d-z{}|#]+/g;
  5.     let match = pattern.exec(stringToDecript)[0];
  6.     if (stringToDecript.length !== match.length) {
  7.         console.log('This is not the book you are looking for.');
  8.     } else {
  9.         let areaOfChars = stringToDecript.split('').map((x) => x.charCodeAt(0) - 3).map((x) => String.fromCharCode(x));
  10.         areaOfChars = areaOfChars.join('');
  11.         for (let i = 0; i < areaOfChars.length; i++) {
  12.             areaOfChars = areaOfChars.replace(wordsToReplace[0],wordsToReplace[1])
  13.         }
  14.         console.log(areaOfChars);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment