hey
I tried to use dot property but the code only worked with brackets. I can’t understand why?
Should we use brackets when there is space in the property.
Here is what I tried to do and didn’t work.
var myObj = {
gift: “pony”,
pet: “kitten”,
bed: “sleigh”
};
function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty(checkProp)){
return myObj.checkProp; /* over here i used dot property. The code worked when I changed it to brackets. return myObj[checkProp];*/
}
else{
return “Not Found”;
}
}
// Test your code by modifying these values
checkObj(“gift”);