Advertisement
Spocoman

Car To Go

Jan 4th, 2022
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function carToGo(input) {
  2.  
  3.     let budget = Number(input[0]);
  4.     let season = input[1];
  5.     let car = '';
  6.     let classs = '';
  7.  
  8.     if (budget > 500) {
  9.         car = `Jeep`;
  10.         classs = `Luxury class`;
  11.         budget *= 0.9;
  12.     }
  13.     else if (budget > 100 && budget <= 500) {
  14.  
  15.         if (season === `Summer`) {
  16.             car = `Cabrio`;
  17.             budget *= 0.45;
  18.         }
  19.         else {
  20.             car = `Jeep`;
  21.             budget *= 0.8;
  22.         }
  23.         classs = `Compact class`;
  24.  
  25.     }
  26.     else if (budget > 0 && budget <= 100) {
  27.  
  28.         if (season === `Summer`) {
  29.             car = `Cabrio`;
  30.             budget *= 0.35;
  31.         }
  32.         else {
  33.             car = `Jeep`;
  34.             budget *= 0.65;
  35.         }
  36.         classs = `Economy class`;
  37.     }
  38.     console.log(classs);
  39.     console.log(`${car} - ${budget.toFixed(2)}`);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement