Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hotelRoom(input) {
- let month = input[0];
- let nights = Number(input[1]);
- let studioPrice = 0;
- let apartmentPrice = 0;
- switch (month) {
- case "May":
- case "October":
- studioPrice = nights * 50;
- if (nights > 14) {
- studioPrice = studioPrice * 0.70;
- } else if (nights > 7) {
- studioPrice = studioPrice * 0.95;
- }
- apartmentPrice = nights * 65;
- break;
- case "June":
- case "September":
- apartmentPrice = nights * 68.70;
- studioPrice = nights * 75.20;
- if (nights > 14) {
- studioPrice = studioPrice * 0.80;
- }
- break;
- case "July":
- case "August":
- studioPrice = nights * 76;
- apartmentPrice = nights * 77;
- break;
- }
- if (nights > 14) {
- apartmentPrice = apartmentPrice * 0.90;
- }
- console.log(`Apartment: ${apartmentPrice.toFixed(2)} lv.`);
- console.log(`Studio: ${studioPrice.toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment