Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(args) {
- let rawKey = args.shift();
- let inputLine = args.shift();
- while (inputLine !== 'Generate') {
- const [command, arg1, arg2, arg3] = inputLine.split('>>>');
- switch (command) {
- case 'Contains':
- if (rawKey.includes(arg1)) {
- console.log(`${rawKey} contains ${arg1}`);
- } else {
- console.log('Substring not found!');
- }
- break;
- case 'Flip':
- const beginIndex = Number(arg2);
- const endIndex = Number(arg3);
- const sliceStr = rawKey.slice(beginIndex, endIndex);
- if (arg1 === 'Upper') {
- rawKey = rawKey.slice(0, beginIndex) + sliceStr.toUpperCase() + rawKey.slice(endIndex);
- console.log(rawKey)
- } else if (arg1 === 'Lower') {
- rawKey = rawKey.slice(0, beginIndex) + sliceStr.toLowerCase() + rawKey.slice(endIndex);
- console.log(rawKey)
- }
- break;
- case 'Slice':
- const bIndex = Number(arg1);
- const eIndex = Number(arg2);
- rawKey.slice(bIndex, eIndex);
- rawKey = rawKey.slice(0, bIndex) + rawKey.slice(eIndex);
- console.log(rawKey)
- break;
- default:
- break;
- }
- inputLine = args.shift();
- }
- console.log(`Your activation key is: ${rawKey}`);
- }
Add Comment
Please, Sign In to add comment