Own property challenge issues

Tell us what’s happening:

I don’t understand why I get
“Dog should have the bark() method as an own property.”

I added .bark method directly to the object, doesn’t that make it it’s own property?

Your code so far


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

function Dog() {
   this.bark = ()=> console.log("Woof!")
}

// Only change code below this line
Dog.prototype = Object.create(Animal.prototype)
Dog.prototype.constructor = Dog



// Only change code above this line

let beagle = new Dog();
console.log(beagle.bark())

Your browser information:

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

Challenge: Add Methods After Inheritance

Link to the challenge:

You need to do what is shown in the example code, but just for Dog instead of Bird.

I get that but previously in the course, when something was defined using prototypes outside the original object, it was saying that it isn’t an “own” type of property

Can you post a link to the challenge you are referring to?

Anyway, if you do what is shown in the example the code will pass.

1 Like

I think it’s this one.

Yeah, I passed the challenge but I would also like to understand what I was doing :sweat_smile:

I’m actually not sure why it says:

Dog should have the bark() method as an own property.

That seems to be a mistake if the challenge is expecting it to be a prototype method.

Edit: I opened an issue for it.

1 Like

That’s also what I thought.
Thank you :smiley:

1 Like