Don't understand the purpose of "let" in the Understand Own Properties Challenge

Can pass the challenge but having trouble understanding what purpose “let” serves in the for loop.

Your code so far

function Bird(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)) {

Your browser information:

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


Link to the challenge:

you need to define the variable property, so you put let in front of it

(let is a newer version of var if you have not yet met it, with also a few differences)

I will give you an example try to execute these two codes;

for (let i=0; i<3;i++){console.log(i); } console.log(i);

for (var i=0; i<3;i++){console.log(i); } console.log(i);

the first example will give an error.

Var variables can be accessed from anywhere in a JavaScript program.
Let is a local variable.

Rather than trying to re-explain the wheel, here’s a link that seems to do a good job:

Bottom line: Always use let or const to declare variables. Most people will tell you to always start with const and then change it to let if the value needs to change. But there are some obvious cases where you will always use let (such as a counter in a for loop).

Solved the confusion. I think I was looking at it too literally and missed that “property” is a declared variable within the loop. Thank you!