Advertisement
Liliana797979

easter eggs battle

Jan 1st, 2021
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function easterEggsBattle(input) {
  2.     let countEggs1 = Number(input[0]);
  3.     let countEggs2 = Number(input[1]);
  4.     let winner = input[2];
  5.     index = 1;
  6.     let battle = input[index];
  7.    
  8.  
  9.     while (battle !== "End of battle") {
  10.         console.log(`Player one has ${countEggs1} eggs left.`);
  11.  
  12.         console.log(`Player two has ${countEggs2} eggs left.`);
  13.  
  14.         break;
  15.     }
  16.    
  17.     if (playerOne < winner) {
  18.         console.log(`Player one is out of eggs. Player two has ${countEggs2} eggs left.`);
  19.     } else if (playerTwo > winner) {
  20.         console.log(`Player two is out of eggs. Player one has ${countEggs1} eggs left.`);
  21.     }
  22. }
  23.  
  24. easterEggsBattle(["5", "4", "one", "two", "one", "two", "two", "End of battle"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement