Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function familyTrip(input) {
- let budget = Number(input[0]);
- let nights = Number(input[1]);
- let pricePerNight = Number(input[2]);
- let extraCostsPercentage = Number(input[3]);
- let allNights = nights * pricePerNight;
- if (nights > 7) {
- allNights = nights * (pricePerNight - (pricePerNight * 5 / 100));
- }
- let allCosts = allNights + budget * extraCostsPercentage / 100;
- if (allCosts <= budget) {
- console.log(`Ivanovi will be left with ${(budget - allCosts).toFixed(2)} leva after vacation.`);
- } else {
- console.log(`${(allCosts - budget).toFixed(2)} leva needed.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment