Advertisement
dilyana2001

Untitled

Jun 15th, 2021
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tseamAccount(strArr) {
  2.     let acc = strArr.shift().split(' ')
  3.     for (let line of strArr) {
  4.         let [command, game] = line.split(' ')
  5.         if (command === 'Install') {
  6.             if (!acc.includes(game)) {
  7.                 acc.push(game)
  8.             }
  9.         } else if (command === 'Uninstall') {
  10.             if (acc.includes(game)) {
  11.                 let index = acc.indexOf(game);
  12.                 acc.splice(index, 1)
  13.             }
  14.         } else if (command === 'Update') {
  15.             if (acc.includes(game)) {
  16.                 let index = acc.indexOf(game);
  17.                 acc.splice(index, 1)
  18.                 acc.push(game)
  19.             }
  20.         } else if (command === 'Expansion') {
  21.             let [nameOfgame, exapnsOfGame] = game.split('-')
  22.             if (acc.includes(nameOfgame)) {
  23.                 let index = acc.indexOf(nameOfgame);
  24.                 acc.splice(index, 1, nameOfgame, `${nameOfgame}:${exapnsOfGame}`)
  25.             }
  26.         } else if (command === 'Play!') {
  27.             console.log(acc.join(' '))
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement