Advertisement
Guest User

Untitled

a guest
Nov 16th, 2023
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tseamAccount(input) {
  2.     let account = input[0];
  3.     let accountArr = account.split(" ");
  4.  
  5.     input.splice(0, 1);
  6.  
  7.     let command = [];
  8.  
  9.     for (i = 0; i < input.length; i++) {
  10.         command = input[i].split(" ");
  11.  
  12.         if (command[0] === 'Install' && accountArr.includes(command[1]) === false) {
  13.             accountArr.push(command[1]);
  14.         }
  15.         else if (command[0] === 'Uninstall' && accountArr.includes(command[1]) === true) {
  16.             for (j = 0; j < accountArr.length; j++) {
  17.                 if (accountArr[j] === command[1]) {
  18.                     accountArr.splice(j, 1);
  19.                 }
  20.             }
  21.         }
  22.         else if (command[0] === 'Update' && accountArr.includes(command[1]) === true) {
  23.             for (j = 0; j < accountArr.length; j++) {
  24.                 if (accountArr[j] === command[1]) {
  25.                     accountArr.splice(j, 1);
  26.                     accountArr.push(command[1]);
  27.                 }
  28.             }
  29.         }
  30.         else if (command[0] === 'Expansion') {
  31.             let expArr = command[1].split("-");
  32.             for (j = 0; j < accountArr.length; j++) {
  33.                 if (accountArr[j] === expArr[0]) {
  34.                    // accountArr[j] = accountArr[j] + " " + accountArr[j] + ":" + expArr[1];
  35.                     accountArr.splice(j + 1, 0, `${expArr[0]}:${expArr[1]}`);
  36.                     break;
  37.                 }
  38.             }
  39.         } else if (command[0] === "Play!") {
  40.             break;
  41.         }
  42.     }
  43.  
  44.     console.log(accountArr.join(" "));
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement