Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function activationKey(input) {
- let rawKey = input.shift();
- for (let line of input) {
- if (line === "Generate") {
- break;
- }
- let command = line.split(">>>");
- let token = command[0];
- switch (token) {
- case "Slice": {
- let startIndex = Number(command[1]);
- let endIndex = Number(command[2]);
- rawKey=rawKey.substring(0,startIndex)+rawKey.substring(endIndex)
- console.log(rawKey)
- }
- break;
- case "Flip": {
- let mpt = ""
- let upOrLow = command[1];
- let startIndex = Number(command[2]);
- let endIndex = Number(command[3]);
- let buff = rawKey.substring(startIndex, endIndex)
- if (upOrLow === "Upper") {
- mpt = rawKey.substring(startIndex, endIndex).toUpperCase();
- rawKey = rawKey.replace(buff, mpt);
- console.log(rawKey)
- } else if(upOrLow === "Lower") {
- mpt = rawKey.substring(startIndex, endIndex).toLowerCase();
- rawKey = rawKey.replace(buff, mpt);
- console.log(rawKey)
- }
- }
- break;
- case "Contains": {
- let substring = command[1];
- if (rawKey.includes(substring)) {
- console.log(`${rawKey} contains ${substring}`);
- } else {
- console.log("Substring not found!");
- }
- }
- break;
- }
- }
- console.log(`Your activation key is: ${rawKey}`);
- }
Add Comment
Please, Sign In to add comment