Advertisement
Spocoman

06. Theatre Promotions(with ternary operator)

Jan 12th, 2022 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function theatrePromotions(day, age) {
  2.     let sum = 0;
  3.  
  4.     if(age >= 0 && age < 123) {
  5.         if (day === "Weekday") {
  6.             sum = age > 18 && age <= 64 ? 18 : 12;
  7.         } else if (day === "Weekend") {
  8.             sum = age > 18 && age <= 64 ? 20 : 15;
  9.         } else if (day === "Holiday"){
  10.             sum = age <= 18 ? 5 : age > 64 ? 10 : 12;
  11.         }
  12.     }
  13.     console.log(sum === 0 ? "Error!" : `${sum}$`);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement