Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function decode(input) {
- let start = Number(input.shift());
- let end = Number(input.shift());
- let correct = input.shift();
- let text = input.shift();
- let regex = /[A-Z][a-zA-Z]+[A-Z]/;
- let [result] = regex.exec(text);
- let country = result.substr(0,start)+correct.toLocaleLowerCase()+result.substr(end+1).toLocaleLowerCase();
- regex = /(\d{3}\.?\d*)/gm;
- let match;
- let ascii=[];
- while (match = regex.exec(text)) {
- ascii.push(Math.ceil(Number(match[1])));
- }
- let city = String.fromCharCode(ascii.shift()).toLocaleUpperCase();
- for (const asciiElement of ascii) {
- city+= String.fromCharCode(asciiElement);
- }
- console.log(`${country} => ${city}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement