Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var car = function(make, model, year, color) {
- this.make = make;
- this.model = model;
- this.year = year;
- this.color = color;
- };
- car.prototype.getCarInfo = function() {
- var info = "Your car is a " + this.color + " " + this.make + " " + this.model + ", year " + this.year;
- return info;
- };
- var car1 = new car("Toyota", "Camry", 2014, "Barcelona Red");
- var car2 = new car("Dodge", "Ram", 2006, "White");
- console.log(car1.getCarInfo());
- console.log(car2.getCarInfo());
Add Comment
Please, Sign In to add comment