Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Car = function (mark, color, distance) {
- this.mark = mark;
- this.color = color;
- this.distance = distance;
- this.printCarInfo = function () {
- console.log(this.mark + ' o kolorze: ' + this.color + ' przejchał ' + this.distance);
- }
- this.drive = function (km) {
- this.distance += km;
- }
- };
- Car.prototype.visits = [];
- Car.prototype.addVisit = function (visitDate) {
- this.visits.push(visitDate);
- };
- Car.prototype.getVisits = function () {
- return this.visits;
- };
- var fiat = new Car('Fiat', 'Red', 187000);
- console.log(fiat.printCarInfo());
- fiat.addVisit('2015');
- fiat.addVisit('2016');
- fiat.addVisit('2017');
- fiat.addVisit('Engine blow');
- fiat.addVisit('2018');
- fiat.addVisit('2019');
- fiat.addVisit('180000 -> Panie niemiec płakał');
- console.log(fiat.visits);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement