Facebook
From Bistre Curlew, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 129
  1. function solution (input){
  2.     let typeCruise=input.shift();
  3.     let typeCabine=input.shift();
  4.     let countNights=Number(input.shift());
  5.  
  6.     totalPrice=0;
  7.     switch(typeCruise){
  8.         case"Mediterranean":
  9.         switch(typeCabine){
  10.         case "standard cabin":totalPrice=countNights*27.5; break;
  11.         case "cabin with balcony":totalPrice=countNights*30.20;break;
  12.         case "apartment":totalPrice=countNights*40.50;break;
  13.         }break;
  14.         case"Adriatic":
  15.         switch(typeCabine){
  16.         case "standard cabin":totalPrice=countNights*22.99; break;
  17.         case "cabin with balcony":totalPrice=countNights*25.00;break;
  18.         case "apartment":totalPrice=countNights*34.99;break;
  19.         }break;
  20.         case"Aegean":
  21.         switch(typeCabine){
  22.         case "standard cabin":totalPrice=countNights*23.00; break;
  23.         case "cabin with balcony":totalPrice=countNights*26.60;break;
  24.         case "apartment":totalPrice=countNights*39.80;break;
  25.         }break;
  26.     }
  27.     if (countNights>7){
  28.         totalPrice=totalPrice*0.75;
  29.     }
  30.     console.log(`Annie's holiday in the ${typeCruise} sea costs ${(totalPrice*4).toFixed(2)} lv.`);
  31.  
  32. }
  33.  
  34. solution([ 'Adriatic', 'apartment', '5', '' ]);