Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function easterShop(input) {
- let eggs = Number(input[0]);
- let totalSumEggs = Number(input[1]);
- while(totalSumEggs !== "Close") {
- if (totalSumEggs === eggs) {
- totalSumEggs = true;
- break;
- }
- index++;
- totalSumEggs = input[index];
- if (totalSumEggs === "Close") {
- console.log(`Store is closed!`);
- console.log(`${totalSumEggs} eggs sold.`);
- } else {
- console.log(`Not enough eggs in store!`);
- console.log(`You can buy only ${eggs - totalSumEggs}.`);
- }
- }
- easterShop(["13", "Buy", "8", "Fill", "3", "Buy", "10"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement