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