Advertisement
Malinov

Activation Keys

Aug 4th, 2021
1,261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function activationKeys(input) {
  2.  
  3.     let rawKey = input.shift();
  4.  
  5.     let [command, ...tokens] = input.shift().split('>>>');
  6.  
  7.     while (command !== 'Generate') {
  8.  
  9.         if (command === 'Slice') {
  10.             let start = Number(tokens[0]);
  11.             let end = Number(tokens[1]);
  12.             let word = rawKey.slice(start, end);
  13.             rawKey = rawKey.replace(word, '');
  14.             console.log(rawKey);
  15.         } else if (command === 'Flip') {
  16.  
  17.             let start = Number(tokens[1]);
  18.             let end = Number(tokens[2]);
  19.  
  20.             if (tokens[0] === 'Upper') {
  21.                 let word = rawKey.slice(start, end);
  22.                 rawKey = rawKey.split(word).join(word.toLocaleUpperCase());
  23.                 console.log(rawKey);
  24.             } else {
  25.                 let word = rawKey.slice(start, end);
  26.                 rawKey = rawKey.split(word).join(word.toLocaleLowerCase());
  27.                 console.log(rawKey);
  28.             }
  29.         } else {
  30.  
  31.             let cont = rawKey.includes(tokens[0]);
  32.             if (cont) {
  33.                 console.log(`${rawKey} contains ${tokens[0]}`);
  34.             } else {
  35.                 console.log('Substring not found!');
  36.             }
  37.         }
  38.  
  39.         [command, ...tokens] = input.shift().split('>>>');
  40.     }
  41.  
  42.     console.log(`Your activation key is: ${rawKey}`);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement