Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let char = input.shift();
- input.pop();
- let newName = '';
- for (const line of input) {
- let command = line.split(' ');
- let inNum = Number(command[1]);
- switch (command[0]) {
- case "GladiatorStance":
- char = char.toUpperCase();
- console.log(char)
- break;
- case "DefensiveStance":
- char = char.toLowerCase();
- console.log(char);
- break;
- case "Dispel":
- if (char.length > inNum) {
- let toBeReplaced = char.charAt(inNum)
- char = char.replace(toBeReplaced, command[2])
- console.log("Success!");
- } else {
- console.log('Dispel too weak.')
- }
- break;
- case "Target":
- if (command[1] === 'Change') {
- let replaceWord = command[2]
- let replacement = command[3];
- char = char.replace(replaceWord, replacement);
- console.log(char);
- }
- if (command[1] === 'Remove') {
- let removeWord = command[2];
- char = char.replace(removeWord,'');
- console.log(char)
- }
- break;
- default:
- console.log("Command doesn't exist!");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement