Liliana797979

problem - final exam - fundamentals

Aug 4th, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.      
  3. function solve(a) {
  4.     let action = a.shift().split(' - ')
  5.  
  6.     // while (action[0] !== 'End') {
  7.     //     let b = action[0]
  8.     //     if (b === 'CastSpell') {
  9.     //         let [_, name, MP, spellName] = action;
  10.     //         console.log(_);
  11.     //         console.log(name);
  12.     //         console.log(MP);
  13.     //         console.log(spellName);
  14.     //     } else if (b === 'TakeDamage') {
  15.     //         let [_, name, MP, spellName] = action;
  16.     //         console.log('--------------');
  17.     //         console.log(_);
  18.     //         console.log(name);
  19.     //         console.log(MP);
  20.     //         console.log(spellName);
  21.     //     }
  22.     //     action = a.shift().split(' - ')
  23.     // }
  24.  
  25.      while (action[0] !== 'End') {
  26.                 let b = action[0]
  27.  
  28.         switch (b) {
  29.             case 'CastSpell':
  30.                 let [_,name,MP,spellName] = action;
  31.                             console.log(_);
  32.                             console.log(name);
  33.                             console.log(MP);
  34.                             console.log(spellName);
  35.                 break;
  36.             case 'TakeDamage':
  37.                 let [_,name,MP,spellName] = action;
  38.                 console.log('--------------');
  39.                             console.log(_);
  40.                             console.log(name);
  41.                             console.log(MP);
  42.                             console.log(spellName);
  43.                 break;
  44.         }
  45.         action = a.shift().split(' - ')
  46.     }
  47. }
  48. solve([
  49.     'CastSpell - Tyris - 1000 - Fireball',
  50.     'TakeDamage - Tyris - 99 - Fireball',
  51.     'End'
  52. ])
Advertisement
Add Comment
Please, Sign In to add comment