For ... in ... syntax question

I’m working on the OOP JavaScript lessons, and I ran into a point of confusion regarding the syntax of for/in loops. I am iterating over the following example object’s properties like so:

let canary = { name: 'Tweety', numLegs: 2 } 
// Example uses a constructor, but I wrote it as a literal for brevity
let ownProps = []
for (prop in canary)
    if (canary.hasOwnProperty(prop) { ownProps.push(prop) };

When I write up this exercise and execute it with Node, it works just fine. However, for FCC’s tests, it only works if declare the prop value first, like so:
for (let prop in canary) // using let keyword before prop

Was wondering if not declaring prop in the loop is a syntax error, and if so, why doesn’t Node complain about the error?

When you are testing your solutions outside of freeCodeCamp, be sure that you are using strict mode. The problem is that prop is not declared. You want for (let prop in canary)

Thanks for the quick reply! When I put "using strict"; in my JS file, Node gave me the error I expected.

I’m glad I could help. Happy coding!