Hi everyone!
I am currently reviewing my basic JS algorithm and was just solving the check for properties section.
My question is if I use the ‘.’ dot notation to return the value of the property the test will not past however if I use the ‘[]’ bracket notation to return the property’s value it passes the test. I assume it is because the function is passing the property as value to the argument that’s why we must use the bracket notation to return the value of the property, am I correct?
here is the code:
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp)) return myObj[checkProp];
return "Not Found";
}
// Test your code by modifying these values
checkObj("gift");