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