Why do you check if beagle has the property ‘property’ first? From the function, is beagle not supposed to be guaranteed to have all the properties in Dog? So aren’t we supposed to check if the property is in Dog first, then if it took in a variable, it wouldn’t be, so it would be in beagle?
function Dog(name) {
this.name = name;
}
Dog.prototype.numLegs = 4;
let beagle = new Dog("Snoopy");
let ownProps = [];
let prototypeProps = [];
// Only change code below this line
for (let property in beagle){
if(beagle.hasOwnProperty(property)){
ownProps.push(property)
} else{
prototypeProps.push(property)
}
}
Challenge: Iterate Over All Properties
Link to the challenge: