bebo231312312321

Untitled

Apr 1st, 2023
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function activationKeys(input) {
  2.     let key = input.shift()
  3.     function contains(s) {
  4.         key.includes(s) ? console.log(`${key} contains ${s}`) : console.log('Substring not found!')
  5.     }
  6.     function slice(a, b) {
  7.         key = key.substring(0, a) + key.substring(b)
  8.         console.log(key)
  9.     }
  10.     function raw(a, b, c) {
  11.         let searchKey = key.substring(b, c)
  12.         key = key.replace(searchKey,
  13.             a === "Upper" ? searchKey.toLocaleUpperCase() : searchKey.toLocaleLowerCase())
  14.         console.log(key)
  15.     }
  16.     let line = input.splice(0, input.indexOf("Generate")).forEach(el => {
  17.         const [command, a, b, c,] = el.split(">>>").map(el => (isNaN(el) ? el : Number(el)))
  18.         switch (command) {
  19.             case "Slice": { slice(a, b) } break; case "Flip": { raw(a, b, c) } break;
  20.             case "Contains": { contains(a) } break;
  21.         }
  22.     });
  23.     console.log(`Your activation key is: ${key}`)
  24. }
Add Comment
Please, Sign In to add comment