Reset an Inherited Constructor Property[Solved]

Reset an Inherited Constructor Property[Solved]
0

#1

Tell us what’s happening:
beagle.constructor should return Dog.
This is wrong what to do?

Your code so far



function Animal() { }
function Bird() { }
function Dog() { }

Bird.prototype = Object.create(Animal.prototype);
Dog.prototype = Object.create(Animal.prototype);

// Add your code below this line
Bird.prototype.constructor=Bird;
 
let duck = new Bird();
let beagle = new Dog();

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/reset-an-inherited-constructor-property


#2

You have added this for bird but not for Dog.
Add for Dog in same way.


#3

Dog.prototype.constructor=Dog;

This is my new code but now
duck.constructor should return Bird.
This is wrong.


#4

You need to add both.
Instructions clearly say:
duck.constructor and beagle.constructor return their respective constructors.


#5

Yes thank you this is right.