Advertisement
Spocoman

04. Car To Go

Dec 22nd, 2021 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function carToGo(input) {
  2.     let budget = parseFloat(input[0]);
  3.     let season = input[1];
  4.     let car = 'Jeep';
  5.     let carClass = 'Luxury class';
  6.  
  7.     if (budget > 500) {
  8.         budget *= 0.9;
  9.     } else if (budget > 100) {
  10.         if (season === 'Summer') {
  11.             car = 'Cabrio';
  12.             budget *= 0.45;
  13.         } else {
  14.             budget *= 0.8;
  15.         }
  16.         carClass = 'Compact class';
  17.  
  18.     } else if (budget > 0) {
  19.         if (season === 'Summer') {
  20.             car = 'Cabrio';
  21.             budget *= 0.35;
  22.         } else {
  23.             budget *= 0.65;
  24.         }
  25.         carClass = 'Economy class';
  26.     }
  27.  
  28.     console.log(`${carClass}\n${car} - ${budget.toFixed(2)}`);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement