Reputation: 1195
LivingThing.call
isn't working. The only property that's created on object creation is the description property. - why? I've checked this multiple times but something keeps eluding me.
function LivingThing(name,sex,distance,attributes,health,level=1){
this.name=name;
this.sex=sex;
this.distance= distance;
this.attributes=attributes;
this.health=health;
this.level= level;
}
function Animal(name,sex,distance,description,attributes,health,level){
LivingThing.call(name,sex,distance,attributes,health,level);
this.description= description;
}
Animal.prototype=Object.create(LivingThing.prototype);
Animal.prototype.constructor= Animal;
Upvotes: -1
Views: 49
Reputation: 781096
You forgot to pass the context argument to LivingThing
:
function Animal(name,sex,distance,description,attributes,health,level){
LivingThing.call(this,name,sex,distance,attributes,health,level);
this.description= description;
}
Upvotes: 3