You created this here
But you are not supposed to.
Let’s take a close look at what this part of the code says here
if(obj.hasOwnProperty(checkProp)){
return obj[checkProp];
}
else{return "Not Found"};
What that is saying is if the obj has a property of checkProp then return its value otherwise return Not Found.
Remember that obj and checkProp are parameters and act as placeholders for the real values for when we call the function.
This is an example function call
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift")
You can see in that function call we have an object
{gift: "pony", pet: "kitten", bed: "sleigh"},
and a property name
"gift"
With that function call, we check if object has a property of gift.
Since it does, then we return the value which is "pony"
Here is another function call that I just made up
checkObj({name: "Jessica", country: "USA"}, "city")
With this function call, we are checking if the property of city exists in this object here
{name: "Jessica", country: "USA"}
Since city is not a property, then we return Not Found.
Your current code only tests for these given properties
obj={
"gift":"pony",
"pet":"kitten",
"bed":"sleigh",
"city":"Seattle"
};
But what about these given properties I just made up?
{name: "Jessica", country: "USA"}
Are you going to add that to your object you created?
No.
That is not practical at all.
We don’t want to continually have to add properties to an object we created just so we can test our function.
Hope that is clearer