Guest User

Untitled

a guest
May 21st, 2020
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fitnessCard(input){
  2.     let haveMoney = Number(input.shift());
  3.     let sex = input.shift();
  4.     let age = Number(input.shift());
  5.     let sport = input.shift();
  6.  
  7.     let cardPrice = 0;
  8.  
  9.     if ( sex === "m"){
  10.         if (sport === "Gym"){
  11.             cardPrice = 42;
  12.             if (age <= 19){
  13.                 cardPrice = cardPrice * 0.80;
  14.             }
  15.         }else if (sport === "Boxing"){
  16.             cardPrice = 41;
  17.             if (age <= 19){
  18.                 cardPrice = cardPrice * 0.80;
  19.             }
  20.         }else if (sport === "Yoga"){
  21.             cardPrice = 45;
  22.             if ( age <=19){
  23.                 cardPrice = cardPrice * 0.80;
  24.             }
  25.         }else if (sport === "Zumba"){
  26.             cardPrice = 34;
  27.             if (age <= 19){
  28.                 cardPrice = cardPrice * 0.80;
  29.             }
  30.         }else if ( sport === "Dance"){
  31.             cardPrice = 51;
  32.             if (age <= 19){
  33.                 cardPrice = cardPrice * 0.80;
  34.             }
  35.         }else if (sport === "Pilates"){
  36.             cardPrice = 39;
  37.             if (age <= 19){
  38.                 cardPrice = cardPrice * 0.80;
  39.             }
  40.         }
  41.     }else if ( sex === "f"){
  42.         if (sport === "Gym"){
  43.             cardPrice = 35;
  44.             if (age <= 19){
  45.                 cardPrice = cardPrice * 0.80;
  46.             }
  47.         }else if (sport === "Boxing"){
  48.             cardPrice = 37;
  49.             if (age <= 19){
  50.                 cardPrice = cardPrice * 0.80;
  51.             }
  52.         }else if (sport === "Yoga"){
  53.             cardPrice = 42;
  54.             if ( age <=19){
  55.                 cardPrice = cardPrice * 0.80;
  56.             }
  57.         }else if (sport === "Zumba"){
  58.             cardPrice = 31;
  59.             if (age <= 19){
  60.                 cardPrice = cardPrice * 0.80;
  61.             }
  62.         }else if ( sport === "Dance"){
  63.             cardPrice = 53;
  64.             if (age <= 19){
  65.                 cardPrice = cardPrice * 0.80;
  66.             }
  67.         }else if (sport === "Pilates"){
  68.             cardPrice = 37;
  69.             if (age <= 19){
  70.                 cardPrice = cardPrice * 0.80;
  71.             }
  72.         }
  73.        
  74.     }
  75. if (haveMoney >= cardPrice){
  76.     console.log(`You purchased a 1 month pass for ${sport}.`)
  77. }else{
  78.     let difference = cardPrice - haveMoney;
  79.     console.log(`You don't have enough money! You need $${difference.toFixed(2)} more.`)
  80. }
  81.  
  82. }
Add Comment
Please, Sign In to add comment