Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tourAgency(input) {
- let city = input[0];
- let extras = input[1];
- let vip = input[2];
- let numberNights = Number(input[3]);
- let pricePerNight = 0;
- if (numberNights < 1) {
- console.log("Days must be positive number!");
- return;
- }
- if (
- (city !== "Bansko" &&
- city !== "Borovets" &&
- city !== "Varna" &&
- city !== "Burgas") ||
- (extras !== "noEquipment" &&
- extras !== "withEquipment" &&
- extras !== "noBreakfast" &&
- extras !== "withBreakfast")
- ) {
- console.log("Invalid input!");
- return;
- }
- if (numberNights > 7) {
- numberNights -= 1;
- }
- if (city === "Bansko" || city === "Borovets") {
- if (extras === "withEquipment") {
- pricePerNight = 100;
- if (vip === "yes") {
- pricePerNight *= 0.9;
- }
- } else {
- pricePerNight = 80;
- if (vip === "yes") {
- pricePerNight *= 0.95;
- }
- }
- } else if (city === "Varna" || city === "Burgas") {
- pricePerNight = 130;
- if (extras === "withBreakfast") {
- pricePerNight = 130;
- if (vip === "yes") {
- pricePerNight *= 0.88;
- }
- } else {
- pricePerNight = 100;
- if (vip === "yes") {
- pricePerNight * 0.93;
- }
- }
- }
- console.log(
- `The price is ${(numberNights * pricePerNight).toFixed(
- 2
- )}lv! Have a nice time!`
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement