Understand Own Properties - test fails for supplied solution

I was doing the “Object Oriented Programming: Understand Own Properties” challenge. I got the program to work but when I ran the tests I got this error message

You should solve this challenge without hardcoding the ownProps array.

I don’t understand “hardcoding”
I don’t know another way of setting up the ownProps array other than:
Let ownProps = ;

I went to “get help” found the solution which was identical to mine. copied it and ran it and still get the same error message.

Below is the code I use but I can’t Pass the test. It is the same code as the suggested solution.

How can I get credit for completing this challenge?
Is this test for this challenge correct?
Is the solution in the help for this challenge wrong?

function Bird(name) {
  this.name = name;
  this.numLegs = 2;
}

let canary = new Bird("Tweety");
let ownProps = [];
// Add your code below this line
for (let property in canary) {
  if (canary.hasOwnProperty(property)) {
    ownProps.push(property);
  }
}

console.log(ownProps); // prints [ "name", "numLegs" ]

Your code works for me. What errors do you see?

THANKS FOR HELPING!!!

I get the following error when I use the code that I pasted in this question
It complains about “hardcoding” the ownProps

// running tests You should solve this challenge without hardcoding the

ownProps

array. // tests completed // console output

This comment is tripping up the test. Removing it should fix the issue.

1 Like

Thanks for letting me. I really, really appreciate it.

1 Like