Advertisement
vborislavova

08. Hotel Room - Conditional Statements Advanced

Feb 24th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hotelRoom(input) {
  2.     let month = input.shift();
  3.     let night = Number(input.shift());
  4.  
  5.     let totalPriceApart = 0;
  6.     let totalPriceStudio = 0;
  7.  
  8.  
  9.   if (month == "May" && night <= 7 || month == "October" && night <= 7) {
  10.     totalPriceStudio = night * 50;
  11.     totalPriceApart = night * 65;
  12.   } else if (month == "May" && night > 7 && night <=14 || month == "October" && night > 7 && night <=14) {
  13.     totalPriceStudio = (night * 50) * 0.95;
  14.     totalPriceApart = night * 65;
  15.   } else if (month == "May" && night > 14 || month == "October" && night > 14) {
  16.     totalPriceStudio = (night * 50) *  0.70;
  17.     totalPriceApart = (night * 65) * 0.90;
  18.   } else if (month == "June" || month == "September") {
  19.     totalPriceStudio = night * 75.20;
  20.     totalPriceApart = night * 68.70;
  21.     if (night > 14) {
  22.         totalPriceStudio = (night * 75.20) * 0.80;
  23.         totalPriceApart = (night * 68.70) * 0.90;
  24.     }
  25.   } else if (month == "July" || month == "August") {
  26.     totalPriceStudio = night * 76;
  27.     totalPriceApart = night * 77;
  28.     if (night > 14) {
  29.       totalPriceApart = (night * 77) * 0.90;
  30.     }
  31.   }
  32.  
  33.   console.log(`Apartment: ${totalPriceApart.toFixed(2)} lv.`);
  34.   console.log(`Studio: ${totalPriceStudio.toFixed(2)} lv.`);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement