Using hasOwnProperty

Im learning to use hasOwnProperty, and in 1 test
image
I dont know why it prints out the property name, but when check again it returns false :((
Can anyone explain it, thanks a lot :slight_smile:

When you use hasOwnProperty you have to pass a string version of the property name, e.g. “name”. The loop does that for you (because at each iteration it makes a prop variable and sets it equal to a property, however since you cannot set a variable equal to an identifier, you have to make the identifier a string), so it works in the case above.