Advertisement
dagrizzly

Untitled

Jun 3rd, 2021
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input){
  2.  
  3.     //determine engine volume
  4.     let enginePower = 200;
  5.     let engineVolume = 3500;
  6.     if (input.power <= 90){
  7.         enginePower = 90;
  8.         engineVolume = 1800;
  9.     }else if(input.power <= 120){
  10.         enginePower = 120;
  11.         engineVolume = 2400;
  12.     }
  13.  
  14.     //determine wheelsize
  15.     let wheel = wheelSize(input.wheelsize);
  16.     function wheelSize(d){
  17.         let res = d;
  18.         if (d % 2 === 0){
  19.             return res = d - 1;
  20.         }
  21.         return res;
  22.     }
  23.  
  24.  
  25.     let car ={
  26.         model: input.model,
  27.         engine: {
  28.             power: enginePower,
  29.             volume: engineVolume
  30.         },
  31.         carriage:{
  32.             type: input.carriage,
  33.             color: input.color
  34.         },
  35.         wheelsize:[wheel, wheel, wheel, wheel]
  36.     }
  37.  
  38.     return car;
  39.    
  40. }
  41.  
  42.  
  43.  
  44. console.log(solve({
  45.     model: 'Brichka',
  46.     power: 65,
  47.     color: 'white',
  48.     carriage: 'hatchback',
  49.     wheelsize: 16
  50. }
  51. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement