Advertisement
Guest User

Untitled

a guest
May 25th, 2021
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cinemaj(args) {
  2.   let seats = Number(args[0]);
  3.   let i = 1;
  4.   let people;
  5.   let profit = 0;
  6.  
  7.   while ((people = args[i]) !== 'Movie time!') {
  8.     people = Number(people)
  9.     if (seats - people >= 0) {
  10.       seats -= people;
  11.       profit += people * 5;
  12.       if (people % 3 === 0) {
  13.         profit -= 5;
  14.       }
  15.     } else {
  16.       console.log('The cinema is full.');
  17.       break;
  18.     }
  19.     i++;
  20.   }
  21.   if (people === 'Movie time!') {
  22.     console.log(`There are ${seats} seats left in the cinema.`);
  23.   }
  24.   console.log(`Cinema income - ${profit} lv.`);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement