// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp) == true) {
return myObj[checkProp];
}
else {
return "Not Found"
}
}
// Test your code by modifying these values
myObj("pony");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36.
I have spend a lot of time trying to understand this… and I believe I understand the code but I am also confusing myself. We are using a condition to check if the object has a given property… does (checkProp) mean that we are checking the property of the variable and then if it has it’s own property return true? I kinda get it and kinda don’t - really just confused about (checkProp) party, which I know is the type of function being used
Thank you… that makes more sense now that I am looking at it. checkObj is using the function to check a property of the set of variable… right? Functions have been confusing for me but just gotta do more of them to get it