Tell us what’s happening:
I pass the challenge, but when I put in the console:
console.log(duck.eat());
console.log(beagle.eat());
I saw in the output:
nom nom nom
undefined
nom nom nom
undefined
Why there is undefined
two times and where it comes from?
My code so far
function Animal() { }
Animal.prototype = {
constructor: Animal,
eat: function() {
console.log("nom nom nom");
}
};
// Only change code below this line
let duck = Object.create(Animal.prototype); // Change this line
let beagle = Object.create(Animal.prototype); // Change this line
console.log(duck.eat());
console.log(beagle.eat());
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0
.
Challenge: Inherit Behaviors from a Supertype
Link to the challenge: