-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise07.HotelRoom.js
More file actions
39 lines (30 loc) · 1.21 KB
/
Exercise07.HotelRoom.js
File metadata and controls
39 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function hotelRoom (mounth, overnightStayCount){
let studioPrice = 0;
let apartmentPrice = 0;
if (mounth === `May` || mounth === `October`){
studioPrice = 50;
apartmentPrice = 65;
} else if (mounth === `June` || mounth === `September`){
studioPrice = 75.20;
apartmentPrice = 68.70;
} else if (mounth === `July` || mounth === `August`){
studioPrice = 76;
apartmentPrice = 77;
}
let finalPriceApartment = apartmentPrice * overnightStayCount;
let finalPriceStudio = studioPrice * overnightStayCount;
if (overnightStayCount > 14 && (mounth === `May` || mounth === `October`)){
finalPriceStudio *= 0.70;
} else if (overnightStayCount > 7 && (mounth === `May` || mounth === `October`)){
finalPriceStudio *= 0.95;
} else if (overnightStayCount > 14 && (mounth === `June` || mounth === `September`)){
finalPriceStudio *= 0.80;
}
if (overnightStayCount > 14){
finalPriceApartment *= 0.90;
}
console.log(`Apartment: ${(finalPriceApartment).toFixed(2)} lv.`);
console.log(`Studio: ${(finalPriceStudio).toFixed(2)} lv`);
}
hotelRoom("August",
20);