Advertisement
marinvch

09. Theatre Promotions

Sep 26th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.     let day = args[0];
  3.     let age = Number(args[1]);
  4.     let price = 0;
  5.     if (age <= 0) {
  6.         return console.log('Error!')
  7.     }
  8.  
  9.  
  10.     switch (day) {
  11.         case 'Weekday':
  12.             if (age <= 18) {
  13.                 price += 12
  14.             } else if (age <= 64) {
  15.                 price += 18
  16.             } else {
  17.                 price += 12
  18.             }
  19.             console.log(`${price}$`);
  20.             break;
  21.         case 'Weekend':
  22.             if (age <= 18) {
  23.                 price += 15
  24.             } else if (age <= 64) {
  25.                 price += 20
  26.             } else {
  27.                 price += 15
  28.             }
  29.             console.log(`${price}$`);
  30.             break;
  31.         case 'Holiday': {
  32.             if (age <= 18) {
  33.                 price += 5
  34.             } else if (age <= 64) {
  35.                 price += 12
  36.             } else {
  37.                 price += 10
  38.             }
  39.             console.log(`${price}$`);
  40.             break;
  41.  
  42.         }
  43.     }
  44.    
  45. }
  46. solve(['Weekend', 12])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement