Bracket notation works but dot notation does not

Hi, I was doing this challenge but I don’t understand why trying to access the object’s property through dot notation doesn’t work but bracket notation does. Anyone know why is this?

1 Like

With dot notation, you are looking for the property name checkProp while with bracket notation you are looking for the property name stored in the variable checkProp.

3 Likes

Hello and welcome to the FCC community~!

The dot notation obj.checkProp looks for a property that is actually called checkProp.
Dot notation doesn’t play well with variables. The bracket notation obj[checkProp] will look for the property name that matches the value of checkProp. :slight_smile:

2 Likes

I think I get it, thank you!