Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cruiseShip(input) {
- let kindOfCruise = input.shift();
- let kindOfCabin = input.shift();
- let numberOfNights = Number(input.shift());
- let standardCabin = 0;
- let cabinWithBalcony = 0;
- let apartment = 0;
- let nightsPrice = 0;
- let findPrize = (function(standardPrize,balconPrize,apartmentPrize){
- if (kindOfCabin == "standard cabin") {
- standardCabin = standardPrize;
- nightsPrice = (standardCabin * numberOfNights) * 4;
- if (numberOfNights > 7) {
- nightsPrice =( (standardCabin * numberOfNights) * 4) * 0.75;
- }
- }else if(kindOfCabin == "cabin with balcony"){
- cabinWithBalcony = balconPrize;
- nightsPrice =( cabinWithBalcony * numberOfNights) * 4;
- if(numberOfNights > 7){
- nightsPrice = ((cabinWithBalcony * numberOfNights) * 4) * 0.75;
- }
- }else if(kindOfCabin == "apartment"){
- apartment = apartmentPrize;
- nightsPrice = (apartment * numberOfNights) * 4;
- if(numberOfNights > 7){
- nightsPrice =((apartment * nightsPrice) * 4) * 0.75;
- }
- }
- })
- switch (kindOfCruise) {
- case "Mediterranean": findPrize( 27.50, 30.20 ,40.50); break;
- case "Adriatic": findPrize(22.99,25.00, 34.99); break;
- case "Aegean": findPrize(23.00,26.60,39.80);break;
- }
- console.log(`Annie's holiday in the ${kindOfCruise} sea costs ${nightsPrice.toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement