Advertisement
Guest User

Untitled

a guest
May 22nd, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function vacation(groupPeople, typeGroup, dayWeek) {
  2.   const business = 'Business';
  3.   const students = 'Students';
  4.   const regular = 'Regular';
  5.  
  6.   const friday = 'Friday';
  7.   const sunday = 'Sunday';
  8.   const saturday = 'Saturday';
  9.  
  10.   let priceForOne = 0;
  11.  
  12.   if (dayWeek === friday) {
  13.     if (typeGroup === students) {
  14.       priceForOne = 8.45;
  15.     } else if (typeGroup === business) {
  16.       priceForOne = 10.90;
  17.     } else if (typeGroup === regular) {
  18.       priceForOne = 15;
  19.     }
  20.   } else if (dayWeek === saturday) {
  21.     if (typeGroup === students) {
  22.       priceForOne = 9.80;
  23.     } else if (typeGroup === business) {
  24.       priceForOne = 15.60;
  25.     } else if (typeGroup === regular) {
  26.       priceForOne = 20;
  27.     }
  28.   } else if (dayWeek === sunday) {
  29.     if (typeGroup === students) {
  30.       priceForOne = 10.46;
  31.     } else if (typeGroup === business) {
  32.       priceForOne = 16;
  33.     } else if (typeGroup === regular) {
  34.       priceForOne = 22.50;
  35.     }
  36.   }
  37.  
  38.   if (groupPeople >= 30 && typeGroup === students) {
  39.     priceForOne *= 0.85;
  40.   } else if (groupPeople >= 100 && typeGroup === business) {
  41.     groupPeople -= 10;
  42.   } else if (typeGroup === regular && groupPeople >= 10 && groupPeople <= 20) {
  43.     priceForOne *= 0.95;
  44.   }
  45.  
  46.   let totalPrice = priceForOne * groupPeople;
  47.  
  48.   console.log(`Total price: ${totalPrice.toFixed(2)}`);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement