Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function activationKeys(input) {
- let rawKey = input.shift();
- let [command, ...tokens] = input.shift().split('>>>');
- while (command !== 'Generate') {
- if (command === 'Slice') {
- let start = Number(tokens[0]);
- let end = Number(tokens[1]);
- let word = rawKey.slice(start, end);
- rawKey = rawKey.replace(word, '');
- console.log(rawKey);
- } else if (command === 'Flip') {
- let start = Number(tokens[1]);
- let end = Number(tokens[2]);
- if (tokens[0] === 'Upper') {
- let word = rawKey.slice(start, end);
- rawKey = rawKey.split(word).join(word.toLocaleUpperCase());
- console.log(rawKey);
- } else {
- let word = rawKey.slice(start, end);
- rawKey = rawKey.split(word).join(word.toLocaleLowerCase());
- console.log(rawKey);
- }
- } else {
- let cont = rawKey.includes(tokens[0]);
- if (cont) {
- console.log(`${rawKey} contains ${tokens[0]}`);
- } else {
- console.log('Substring not found!');
- }
- }
- [command, ...tokens] = input.shift().split('>>>');
- }
- console.log(`Your activation key is: ${rawKey}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement