MartenBG

Untitled

Feb 18th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. function cookieFactury(input) {
  2. let batchesCount = +(input.shift());
  3.  
  4. for (let i = 1; i <= batchesCount; i++) {
  5. let component = '';
  6. let isEggs = false;
  7. let isFlour = false;
  8. let isShugar = false;
  9. while (true) {
  10. component = input.shift();
  11. if (component == "eggs") {
  12. isEggs = true;
  13. } else if (component == "flour") {
  14. isFlour = true;
  15. } else if (component == "sugar") {
  16. isShugar = true;
  17. } else if (component == "Bake!") {
  18. if (isEggs && isFlour && isShugar) {
  19. console.log(`Baking batch number ${i}...`);
  20. break;
  21. } else {
  22. console.log("The batter should contain flour, eggs and sugar!");
  23. }
  24. }
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment