Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve (input) {
- let singerPrice = input[0];
- let totalSum = 0;
- let guestCount = 0;
- for (let index = 1; index < input.length; index++) {
- if (input[index] === 'The restaurant is full') {
- break;
- }
- let groupCount = input[index];
- guestCount += Number(groupCount);
- if (groupCount < 5) {
- totalSum += groupCount * 100;
- } else {
- totalSum += groupCount * 70;
- }
- }
- if (totalSum >= singerPrice) {
- console.log(`You have ${guestCount} guests and ${totalSum - singerPrice} leva left.`);
- } else {
- console.log(`You have ${guestCount} guests and ${totalSum} leva income, but no singer.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment