Advertisement
bebo231312312321

Untitled

Mar 25th, 2023
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function activationKey(input) {
  2.     let rawKey = input.shift();
  3.  
  4.     for (let line of input) {
  5.         if (line === "Generate") {
  6.             break;
  7.         }
  8.         let command = line.split(">>>");
  9.         let token = command[0];
  10.  
  11.         switch (token) {
  12.             case "Slice": {
  13.                 let startIndex = Number(command[1]);
  14.                 let endIndex = Number(command[2]);
  15.             rawKey=rawKey.substring(0,startIndex)+rawKey.substring(endIndex)
  16.        
  17.                 console.log(rawKey)
  18.             }
  19.                 break;
  20.             case "Flip": {
  21.                 let mpt = ""
  22.                 let upOrLow = command[1];
  23.                 let startIndex = Number(command[2]);
  24.                 let endIndex = Number(command[3]);
  25.                 let buff = rawKey.substring(startIndex, endIndex)
  26.                 if (upOrLow === "Upper") {
  27.                     mpt = rawKey.substring(startIndex, endIndex).toUpperCase();
  28.                     rawKey = rawKey.replace(buff, mpt);
  29.                     console.log(rawKey)
  30.                 } else if(upOrLow === "Lower") {
  31.                     mpt = rawKey.substring(startIndex, endIndex).toLowerCase();
  32.                     rawKey = rawKey.replace(buff, mpt);
  33.                     console.log(rawKey)
  34.                 }
  35.             }
  36.                 break;
  37.             case "Contains": {
  38.                 let substring = command[1];
  39.                 if (rawKey.includes(substring)) {
  40.                     console.log(`${rawKey} contains ${substring}`);
  41.                 } else {
  42.                     console.log("Substring not found!");
  43.                 }
  44.             }
  45.                 break;
  46.  
  47.         }
  48.     }
  49.  
  50.     console.log(`Your activation key is: ${rawKey}`);
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement