That's my first question in this platform. If there is any fault, sorry for this. I could not understand the differences between these two code snippets. I got these errors and I could not understand the reasons.
Dog should inherit the eat() method from Animal.
beagle should be an instanceof Animal.
beagle.eat() should log "nom nom nom"
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;
Dog.prototype.bark= function(){
console.log("Woof!");
}
// Only change code above this line
let beagle = new Dog();
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!")
}
}
// Only change code above this line
let beagle = new Dog();