Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function warriorQuest(input){
- let crypted=input.shift();
- for(let line of input) {
- if(line==="For Azeroth"){
- break;
- }
- let [command,firstValue,secondValue,thirdValue]=line.split(" ");
- if(command==="GladiatorStance"){
- crypted=crypted.toUpperCase();
- console.log(crypted)
- }else if(command==="DefensiveStance"){
- crypted=crypted.toLowerCase();
- console.log(crypted)
- }else if(command==="Dispel"){
- let index=Number(firstValue);
- let letterToReplace=secondValue;
- if(index>=0 && index<crypted.length){
- let toReplace=crypted[index];
- crypted=crypted.replace(toReplace,letterToReplace);
- console.log(`Success!`);
- }else {
- console.log(`Dispel too weak.`);
- }
- }else if(command==="Target"){
- if(firstValue==="Change"){
- while (crypted.includes(secondValue)){
- crypted=crypted.replace(secondValue,thirdValue);
- }
- console.log(crypted)
- }else if(firstValue==="Remove"){
- while(crypted.includes(secondValue)){
- crypted=crypted.replace(secondValue,"");
- }
- console.log(crypted)
- }else {
- console.log(`Command doesn't exist!`)
- }
- }else {
- console.log(`Command doesn't exist!`);
- }
- }
- }
Add Comment
Please, Sign In to add comment