Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cinema(input) {
- let capacityOfHall = input[0];
- let index = 1;
- let people = input[index];
- let totalPeople = 0;
- let totalMoney = 0;
- let isFull = false;
- while (people !== "Movie time!") {
- totalPeople += people;
- if (capacityOfHall < totalPeople) {
- isFull = true;
- break;
- }
- totalMoney += people * 5;
- if (people % 3 === 0) {
- totalMoney -= 5;
- }
- index++;
- people = input[index];
- }
- if (!isFull) {
- let diff = capacityOfHall - totalPeople;
- console.log(`There are ${diff} seats left in the cinema.`);
- } else {
- console.log(`The cinema is full.`);
- }
- console.log(`Cinema income - ${totalMoney} lv.`);
- }
- cinema([60, 10, 6, 3, 20, 15, "Movie time!"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement