Advertisement
Liliana797979

easter shop

Jan 1st, 2021
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function easterShop(input) {
  2.     let eggs = Number(input[0]);
  3.     let totalSumEggs = Number(input[1]);
  4.  
  5.     while(totalSumEggs !== "Close") {
  6.         if (totalSumEggs === eggs) {
  7.             totalSumEggs = true;
  8.             break;
  9.         }
  10.         index++;
  11.         totalSumEggs = input[index];
  12.  
  13.         if (totalSumEggs === "Close") {
  14.             console.log(`Store is closed!`);
  15.             console.log(`${totalSumEggs} eggs sold.`);
  16.  
  17.         } else {
  18.             console.log(`Not enough eggs in store!`);
  19.             console.log(`You can buy only ${eggs - totalSumEggs}.`);
  20.         }
  21.     }
  22.  
  23.  
  24. easterShop(["13", "Buy", "8", "Fill", "3", "Buy", "10"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement