0
Q:

create an object constructor javascript

function ClassMates(name,age){
  this.name=name;
  this.age=age;
  this.displayInfo=function(){
    return this.name + "is " + this.age + "year's old!";
  }
}

let classmate1 = new ClassMates("Mike Will", 15);
classmate.displayInfo(); // "Mike Will is 15 year's old!"
9
function Car(make, model, year) {
  this.make = make;
  this.model = model;
  this.year = year;
}

var car1 = new Car('Eagle', 'Talon TSi', 1993);

console.log(car1.make);
// expected output: "Eagle"
8
function Person(first, last, age, eye) {
  this.firstName = first;
  this.lastName = last;
  this.age = age;
  this.eyeColor = eye;
}
6
function Person(firstName, lastName){
    this.firstName =  firstName;
    this.lastName = lastName;        
}  

let Saad = new Person("Saad", "Mousliki");
0
function Tree(name) {
  this.name = name
}

let theTree = new Tree('Redwood')
console.log('theTree.constructor is ' + theTree.constructor)
0

New to Communities?

Join the community