Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function easterEggsBattle(input) {
- let countEggs1 = Number(input[0]);
- let countEggs2 = Number(input[1]);
- let winner = input[2];
- index = 1;
- let battle = input[index];
- while (battle !== "End of battle") {
- console.log(`Player one has ${countEggs1} eggs left.`);
- console.log(`Player two has ${countEggs2} eggs left.`);
- break;
- }
- if (playerOne < winner) {
- console.log(`Player one is out of eggs. Player two has ${countEggs2} eggs left.`);
- } else if (playerTwo > winner) {
- console.log(`Player two is out of eggs. Player one has ${countEggs1} eggs left.`);
- }
- }
- easterEggsBattle(["5", "4", "one", "two", "one", "two", "two", "End of battle"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement