Why can't I use an object "add methods after inheritance"?

Tell us what’s happening:
Why can’t I use an object “add methods after inheritance”?

I thought I could in the previous lessons.

Your code so far


function Animal() { }
Animal.prototype.eat = function() { console.log("nom nom nom"); };

function Dog() { }

// Only change code below this line

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

Dog.prototype = {
constructor : Dog,
bark : function () {
    console.log("Woof!");
}
}
let beagle = new Dog();
console.log(beagle.constructor);




Your browser information:

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

Challenge: Add Methods After Inheritance

Link to the challenge:

1 Like