Advertisement
ilianrusev

Car Factory

Jan 6th, 2022
953
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(obj) {
  2.     let resultCar = {};
  3.     resultCar.model = obj.model;
  4.  
  5.     if (obj.power <= 90) {
  6.         resultCar.engine = { power: 90, volume: 1800 };
  7.     } else if (obj.power > 90 && obj.power <= 120) {
  8.         resultCar.engine = { power: 120, volume: 2400 };
  9.     } else if (obj.power > 120 && obj.power <= 200) {
  10.         resultCar.engine = { power: 200, volume: 3500 };
  11.     }
  12.  
  13.     resultCar.carriage = {
  14.         type: obj.carriage,
  15.         color: obj.color
  16.     }
  17.  
  18.     resultCar.wheelsize = []
  19.     let newSize = 0;
  20.  
  21.     if (obj.wheelsize % 2 == 0) {
  22.         newSize = obj.wheelsize - 1;
  23.         for (let i = 0; i < 4; i++) {
  24.             resultCar.wheelsize.push(newSize);
  25.  
  26.         }
  27.     } else {
  28.         newSize = obj.wheelsize;
  29.         for (let i = 0; i < 4; i++) {
  30.             resultCar.wheelsize.push(newSize);
  31.  
  32.         }
  33.     }
  34.     return resultCar;
  35.     //console.log(resultCar);
  36. }
Advertisement
RAW Paste Data Copied
Advertisement