If this is the case, then is there an opposite situation where a dot annotation would be required and bracket would not work?
I’m new to all of this, so if bracket is more useful in this way I could just stick to using that. Initially I thought they were the same.
Thanks!
Your code so far
function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty(checkProp)) {
return obj[checkProp];
} else {
return "Not Found";
}
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36.
No, but prefer dot notation where possible because it’s easier to read and easier to type (“I am accessing a property with the key of x on object y”). And bracket notation for when it’s necessary, ie if you need to dynamically look up a property on an object based in some other logic that you need to evaluate first