Tell us what’s happening:
hi there, in code as you will see i used hasOwnProperty to determine whether the “numLegs”, is the property of the new object/instance beagle, i think it should show “true” or maybe “false” but it is showing “undefined”, does it have to do something with the use of 'protoptype ’ or i have made some mistake here.
thnx, constructive criticism appreciated
Your code so far
function Dog(name) {
this.name = name;
Dog.prototype.numLegs=4;
}
// Add your code above this line
let beagle = new Dog("Snoopy");
console.log(beagle.hasOwnProperty(numLegs));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/use-prototype-properties-to-reduce-duplicate-code