Bug in iterate over all properties

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' ] 

Please provide the full code to replicate the issue. Screenshots are very difficult to work with.


Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

I opened an issue for this.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.