Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function vacationPrice(people, group, day) {
- let groupTypes = {
- Students: {
- Friday: 8.45,
- Saturday: 9.80,
- Sunday: 10.46
- },
- Business: {
- Friday: 10.90,
- Saturday: 15.60,
- Sunday: 16
- },
- Regular: {
- Friday: 15,
- Saturday: 20,
- Sunday: 22.50
- }
- }
- let totalPriceDiscount = 0
- if (people >= 30 && group==="Students") {
- let totalPrice = groupTypes[group][day] * people
- totalPriceDiscount = totalPrice - ((15/100) * totalPrice)
- }
- else if (people >= 100 && group==="Business") {
- totalPriceDiscount = groupTypes[group][day] * (people - 10)
- }
- else if (people >= 10 && people <= 20 && group==="Regular") {
- let totalPrice = groupTypes[group][day] * people
- totalPriceDiscount = totalPrice - ((5/100) * totalPrice)
- }
- else {
- totalPriceDiscount = groupTypes[group][day] * people
- }
- console.log(`Total price: ${totalPriceDiscount.toFixed(2)}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement