Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function easterBake(input) {
- let quantity = Number(input.shift());
- let sugarTotal = 0;
- let flourTotal = 0;
- let maxSugar = 0;
- let maxFlour = 0;
- for (let i = 0; i < quantity; i++) {
- let sugar = Number(input.shift());
- let flour = Number(input.shift());
- if (maxSugar < sugar) {
- maxSugar = sugar;
- }
- if (maxFlour < flour) {
- maxFlour = flour;
- }
- sugarTotal += sugar;
- flourTotal += flour;
- }
- console.log(`Sugar: ${Math.ceil(sugarTotal / 950)}`);
- console.log(`Flour: ${Math.ceil(flourTotal / 750)}`);
- console.log(`Max used flour is ${maxFlour} grams, max used sugar is ${maxSugar} grams.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement