Advertisement
raya_petkovaa

secondTask

Feb 21st, 2024
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function vacationPrice(people, group, day) {
  2.  
  3.     let groupTypes = {
  4.         Students: {
  5.             Friday: 8.45,
  6.             Saturday: 9.80,
  7.             Sunday: 10.46
  8.         },
  9.         Business: {
  10.             Friday: 10.90,
  11.             Saturday: 15.60,
  12.             Sunday: 16
  13.         },
  14.         Regular: {
  15.             Friday: 15,
  16.             Saturday: 20,
  17.             Sunday: 22.50
  18.         }
  19.     }
  20.  
  21.     let totalPriceDiscount = 0
  22.  
  23.     if (people >= 30 && group==="Students") {
  24.         let totalPrice = groupTypes[group][day] * people
  25.         totalPriceDiscount = totalPrice - ((15/100) * totalPrice)
  26.     }
  27.     else if (people >= 100 && group==="Business") {
  28.         totalPriceDiscount = groupTypes[group][day] * (people - 10)
  29.     }
  30.     else if (people >= 10 && people <= 20 && group==="Regular") {
  31.         let totalPrice = groupTypes[group][day] * people
  32.         totalPriceDiscount = totalPrice - ((5/100) * totalPrice)
  33.     }
  34.     else {
  35.         totalPriceDiscount = groupTypes[group][day] * people
  36.     }
  37.  
  38.     console.log(`Total price: ${totalPriceDiscount.toFixed(2)}`)
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement