Advertisement
Pijomir

Theatre Promotion

Sep 14th, 2023
891
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function chooseTheatrePromotion(day, age) {
  2.     let price = 0;
  3.     let personByAge = '';
  4.     if (age >= 0 && age <= 18) {
  5.         personByAge = 'kid';
  6.     } else if (age > 18 && age <= 64) {
  7.         personByAge = 'adult';
  8.     } else if (age > 64 && age <= 122) {
  9.         personByAge = 'elder';
  10.     }
  11.  
  12.     switch(personByAge) {
  13.         case 'kid':
  14.             switch(day) {
  15.                 case 'Weekday': price = 12; break;
  16.                 case 'Weekend': price = 15; break;
  17.                 case 'Holiday': price = 5; break;
  18.             }
  19.  
  20.             break;
  21.         case 'adult':
  22.             switch(day) {
  23.                 case 'Weekday': price = 18; break;
  24.                 case 'Weekend': price = 20; break;
  25.                 case 'Holiday': price = 12; break;
  26.             }
  27.  
  28.             break;
  29.         case 'elder':
  30.             switch(day) {
  31.                 case 'Weekday': price = 12; break;
  32.                 case 'Weekend': price = 15; break;
  33.                 case 'Holiday': price = 10; break;
  34.             }
  35.  
  36.             break;
  37.     }
  38.  
  39.     console.log(price === 0 ? 'Error!' : `${price}$`);
  40. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement