Advertisement
Prohause

Minke, decode

Jun 11th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. function decode(input) {
  2. let start = Number(input.shift());
  3. let end = Number(input.shift());
  4. let correct = input.shift();
  5. let text = input.shift();
  6. let regex = /[A-Z][a-zA-Z]+[A-Z]/;
  7.  
  8. let [result] = regex.exec(text);
  9. let country = result.substr(0,start)+correct.toLocaleLowerCase()+result.substr(end+1).toLocaleLowerCase();
  10. regex = /(\d{3}\.?\d*)/gm;
  11.  
  12. let match;
  13. let ascii=[];
  14.  
  15. while (match = regex.exec(text)) {
  16. ascii.push(Math.ceil(Number(match[1])));
  17. }
  18. let city = String.fromCharCode(ascii.shift()).toLocaleUpperCase();
  19. for (const asciiElement of ascii) {
  20. city+= String.fromCharCode(asciiElement);
  21. }
  22. console.log(`${country} => ${city}`);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement