In the last two lines, it has "top" and "middle" on parentheses but on the exercise I did (exercise is below this paragraph), the checkProp part in the second line is not supposed to be in parentheses and the function won’t execute properly if there are parentheses. Why is this?
you have the parenthesis there
do you mean the quotes? ""
it is because checkProp is a variable with a value of string, you do not write variables with quotes
() indicates to JavaScript to evaluate whatever is in the brackets. Most often, this means you’re calling a function. So in this case, JavaScript function call, and this function takes a property name:
myObject.hasOwnProperty("someKey")
“Does myObject have the property with the key "someKey"?”
[] indicates to JavaScript that you are accessing a property on an object (more specifically [] immediately preceded by an object or a reference to an object and with a string in the brackets). So JavaScript object access:
myObject["someKey"]
"Access the value of the property with the key "someKey" on the object myObject"
Because a variable is evaluated to whatever it’s value is, this is also a string in object access:
let myVariableKey = "myKey"
myObject[myVariableKey]