i guess there is a bug in this challenge because it should show error when i run tests but instead it shows success as you can see the code and output in console log even though i know i should use else statement to get desired output but the tests ran successful even with wrong code and wrong output
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 own in beagle){
if(beagle.hasOwnProperty(own)){
ownProps.push(own);
} prototypeProps.push(own);
}
console.log(prototypeProps,ownProps)
==>>> // this gives an output of [ 'name', 'numLegs' ] [ 'name' ]
//correct code below
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 own in beagle){
if(beagle.hasOwnProperty(own)){
ownProps.push(own);
}else {
prototypeProps.push(own);
}
}
console.log(prototypeProps,ownProps)
==>>> // this gives an output of [ 'numLegs' ] [ 'name' ]