Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function activation(input) {
- let rawKeys = input.shift();
- //console.log(rawKeys);
- let line = input.shift();
- rawKeys = String(rawKeys);
- while (line !== "Generate") {
- let [command, mode, firstArgument, secondArgument] = line.split(">>>");
- switch (command) {
- case "Contains":
- let substring = mode;
- if (rawKeys.includes(substring)) {
- console.log(`${rawKeys} contains ${substring}`);
- } else {
- console.log(`Substring not found!`);
- }
- break;
- case "Flip": {
- let startIndex = Number(firstArgument);
- let endIndex = Number(secondArgument);
- if (mode === "Upper")
- let substring = rawKeys.slice(startIndex, endIndex);
- rawKeys = rawKeys.replace(substring.substring.toUpperCase());
- console.log(rawKeys);
- } else {
- let substr = rawKeys.slice(startIndex, endIndex);
- rawKeys = rawKeys.replace(substr.substr.toLowerCase());
- console.log(rawKeys);
- }
- break;
- }
- case "Slice": {
- let startIndex = Number(firstArgument);
- let endIndex = Number(secondArgument);
- let cut = rawKeys.substring(startIndex, endIndex);
- rawKeys = rawKeys.replace(cut, "");
- console.log(rawKeys);
- break;
- }
- }
- line = input.shift();
- console.log(`Your activation key is: ${rawKeys}`);
- }
- activation((["abcdefghijklmnopqrstuvwxyz",
- "Slice>>>2>>>6",
- "Flip>>>Upper>>>3>>>14",
- "Flip>>>Lower>>>5>>>7",
- "Contains>>>def",
- "Contains>>>deF",
- "Generate"])
- );
Advertisement
Add Comment
Please, Sign In to add comment