Advertisement
sanjiisan

Untitled

May 13th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. var Car = function (mark, color, distance) {
  2. this.mark = mark;
  3. this.color = color;
  4. this.distance = distance;
  5. this.printCarInfo = function () {
  6. console.log(this.mark + ' o kolorze: ' + this.color + ' przejchał ' + this.distance);
  7. }
  8. this.drive = function (km) {
  9. this.distance += km;
  10. }
  11. };
  12.  
  13. Car.prototype.visits = [];
  14. Car.prototype.addVisit = function (visitDate) {
  15. this.visits.push(visitDate);
  16. };
  17.  
  18. Car.prototype.getVisits = function () {
  19. return this.visits;
  20. };
  21.  
  22. var fiat = new Car('Fiat', 'Red', 187000);
  23.  
  24. console.log(fiat.printCarInfo());
  25.  
  26. fiat.addVisit('2015');
  27. fiat.addVisit('2016');
  28. fiat.addVisit('2017');
  29. fiat.addVisit('Engine blow');
  30. fiat.addVisit('2018');
  31. fiat.addVisit('2019');
  32. fiat.addVisit('180000 -> Panie niemiec płakał');
  33.  
  34. console.log(fiat.visits);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement