During the exercise, it appears the return obj.checkProp;
would not work because brackets are required to access a variable.
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
.
Challenge: Testing Objects for Properties
Link to the challenge: