Can pass hardcode test

Tell us what’s happening:
the test says that ownProps must not be ‘hardcoded’. It doesn’t look hardcoded to me. Please tell me what in my code qualifies as hardcoded?

Your code so far


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

let canary = new Bird("Tweety");
let ownProps = [];
// Only change code below this line

function propCheck(obj){
let funcProp = [];
for (let property in obj) {
  if(obj.hasOwnProperty(property)) {
  funcProp.push(property);
  }
}
return funcProp;
}

ownProps = propCheck(canary);

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0.

Challenge: Understand Own Properties

Link to the challenge:

I believe that the test suite is getting confused because you are replacing the array ownProps. When I modify your code to not use a function call, it works fine.

Still not working with this. What does it consider ‘hard coding’?

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

let canary = new Bird("Tweety");
let ownProps = [];
// Only change code below this line

  for (let property in canary) {
    if(canary.hasOwnProperty(property)) {
    ownProps.push(property);
    }
  }

//ownProps = propCheck(canary);

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

Oh, I should have seen this. This note is probably what’s doing it.


Edit: yep, that comment is the problem. Remove it and you’re fine.

I think it’s saying that because you are reassigning it.

Nope, looks like Jeremy is right.

Comment removal fixed it. Thanks.
My original code works also.