Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function BachelorParty(input){
- let singer = Number(input.shift());
- let sumPeople = 0;
- let sum = 0;
- let command = input.shift();
- while(command !== 'The restaurant is full'){
- let people = Number(command);
- sumPeople += people;
- if(people < 5){
- sum += people * 100;
- }else if(people >= 5){
- sum += people * 70;
- }
- command = input.shift();
- }
- if(sum >= singer){
- let leftMoney = sum - singer;
- console.log(`You have ${sumPeople} guests and ${leftMoney} leva left.`);
- }else{
- console.log(`You have ${sumPeople} guests and ${sum} leva income, but no singer.`);
- }
- }
- BachelorParty([3200,
- 5,
- 12,
- 6,
- 6,
- 12,
- 'The restaurant is full'
- ]);
Advertisement
Add Comment
Please, Sign In to add comment