Advertisement
DraconiusNX

Untitled

Sep 27th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function rentAcar(data) {
  2.     var budget = Number(data[0]);
  3.     var season = data[1];
  4.     var carType = "";
  5.     var econList = {
  6.         "Summer": { "Cabrio": budget*0.35 },
  7.         "Winter": { "Jeep": budget*0.65 }
  8.     };
  9.     var compList = {
  10.         "Summer": { "Cabrio": budget*0.45 },
  11.         "Winter": { "Jeep": budget*0.80 }
  12.     };
  13.     var luxList = {
  14.         "Summer": { "Jeep": budget*0.90 },
  15.         "Winter": { "Jeep": budget*0.90 }
  16.     };
  17.     if (season === "Summer" && budget <= 500) {
  18.         carType = "Cabrio";
  19.     } else {
  20.         carType = "Jeep";
  21.     }
  22.     if (budget <= 100) {
  23.         console.log(`Economy class`);
  24.         console.log(`${carType} - ${(econList[season][carType]).toFixed(2)}`);
  25.     } else if (budget > 100 && budget <= 500) {
  26.         console.log(`Compact class`);
  27.         console.log(`${carType} - ${(compList[season][carType]).toFixed(2)}`);
  28.     } else {
  29.         console.log(`Luxury class`);
  30.         console.log(`${carType} - ${(luxList[season][carType]).toFixed(2)}`);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement