I don't fully understand this : Understand Own Properties

Tell us what’s happening:
Trying to solve this one
And it gives me the following error
SyntaxError: unknown: Identifier ‘ownProps’ has already been declared (9:4)
But in the example, they did the same
So why does it error?

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
let ownProps = [];

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

console.log(ownProps); 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36.

Challenge: Understand Own Properties

Link to the challenge:

  1. You are declaring twice ownProps
let ownProps = [];
// Only change code below this line
let ownProps = [];

And because you’re using let, it’s helping you out by returning an error (it wouldn’t using var). Also, if you look at the output, the error is on line 9, so you should be able to identify the problem.

  1. I can see another potential issue, you write yourObject.theMethod() without an spacing between the words.
1 Like

Thank u i was able to solve it :3

You are welcome. Keep learning on, and remember to pay attention to what the console logs, it is a fundamental tool.

1 Like