Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function easterDecoration(input) {
- let clients = Number(input.shift());
- let total = 0;
- for (let i = 0; i < clients; i++) {
- let stock = input.shift();
- let counter = 0;
- let sum = 0;
- while (stock !== "Finish") {
- switch (stock) {
- case "basket":
- sum += 1.5;
- break;
- case "wreath":
- sum += 3.8;
- break;
- case "chocolate bunny":
- sum += 7;
- break;
- }
- stock = input.shift();
- counter++;
- }
- if (counter % 2 === 0) {
- sum *= 0.8;
- }
- total += sum;
- console.log(`You purchased ${counter} items for ${sum.toFixed(2)} leva.`);
- }
- console.log(`Average bill per client is: ${(total / clients).toFixed(2)} leva.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement