Advertisement
Guest User

Untitled

a guest
Aug 1st, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function activationKeysProgram(params) {
  2.     let workStr = params.shift();
  3.     let command = params.shift();
  4.     let flag = true;
  5.  
  6.     while (command !== 'Generate') {
  7.         command = command.split('>>>');
  8.  
  9.  
  10.         if (command[0] == 'Contains') {
  11.             if (workStr.includes(command[1])) {
  12.                 console.log(`${workStr} contains ${command[1]}`);
  13.  
  14.             } else {
  15.                 console.log(`Substring not found!`)
  16.                 flag=false
  17.             }
  18.         }
  19.         else if (command[0] == 'Flip') {
  20.             if (command[1] === 'Upper') {
  21.                 command[2]=Number(command[2]);
  22.                 command[3]=Number(command[3]);
  23.                 let str = workStr.substring(command[2], command[3]);
  24.                
  25.                 let upper = str.toUpperCase();
  26.                 workStr = workStr.replace(str, upper);
  27.             }
  28.             else if (command[1] === 'Lower') {
  29.                 command[2]=Number(command[2]);
  30.                 command[3]=Number(command[3]);
  31.                 let str = workStr.substring(command[2], command[3]);
  32.                 let lower = str.toLowerCase();
  33.                 workStr = workStr.replace(str, lower);
  34.             }
  35.         }
  36.         else if (command[0] == 'Slice') {
  37.             command[1]=Number(command[1]);
  38.             command[2]=Number(command[2]);
  39.             let slice = workStr.substring(command[1], command[2]);
  40.             workStr = workStr.replace(slice, '');
  41.         }
  42.  
  43.  
  44.         if(flag == true){
  45.             console.log(workStr);
  46.         }
  47.         flag=true;  
  48.         command = params.shift();
  49.     }
  50.     console.log(`Your activation key is: ${workStr}`);
  51. }
  52. activationKeysProgram([
  53.     'abcdefghijklmnopqrstuvwxyzdef',
  54.     'Slice>>>2>>>6',
  55.     'Flip>>>Upper>>>3>>>14',
  56.     'Flip>>>Lower>>>5>>>7',
  57.     'Contains>>>def',
  58.     'Contains>>>deF',
  59.     'Generate'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement