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