Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cookieFactory(input) {
- let batches = Number(input.shift());
- let countBatches = 0;
- let flourCom = false;
- let eggsCom = false;
- let sugarCom = false;
- let command = input.shift();
- while (countBatches < batches) {
- if (command === "flour") {
- flourCom = true;
- } else if (command === "eggs") {
- eggsCom = true;
- } else if (command === "sugar") {
- sugarCom = true;
- }
- if (command === "Bake!" && (flourCom === false || eggsCom === false || sugarCom === false)) {
- console.log(`The batter should contain flour, eggs and sugar!`);
- }
- if (command === "Bake!" && flourCom === true && eggsCom === true && sugarCom === true) {
- countBatches++;
- console.log(`Baking batch number ${countBatches}...`);
- flourCom = false;
- eggsCom = false;
- sugarCom = false;
- }
- command = input.shift();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment