georgiev955

demo

Sep 20th, 2023
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Car(brand, horsepower, price) {
  2.     return {
  3.         brand,
  4.         horsepower,
  5.         price,
  6.         fuel: 75,
  7.  
  8.         get reduceFuel() {
  9.             return this.fuel;
  10.         },
  11.         set reduceFuel(liters) {
  12.             this.fuel -= liters;
  13.         },
  14.     }
  15. }
  16.  
  17. let myCar = Car('Audi', 313, '37000$');
  18.  
  19. myCar.reduceFuel = 10;
  20. console.log(myCar.reduceFuel);
Advertisement
Add Comment
Please, Sign In to add comment