.hasOwnProperty(propname)
method of objects to determine if that object has the given property name. .hasOwnProperty()
returns true
or false
if the property is found or not.
Example
var myObj = {
top: "hat",
bottom: "pants"
};
myObj.hasOwnProperty("top"); // true
myObj.hasOwnProperty("middle"); // false
checkObj
to test myObj
for checkProp
. If the property is found, return that property's value. If not, return "Not Found"
.
checkObj("gift")
should return "pony"
.
testString: 'assert(checkObj("gift") === "pony", "checkObj("gift")
should return "pony"
.");'
- text: checkObj("pet")
should return "kitten"
.
testString: 'assert(checkObj("pet") === "kitten", "checkObj("pet")
should return "kitten"
.");'
- text: checkObj("house")
should return "Not Found"
.
testString: 'assert(checkObj("house") === "Not Found", "checkObj("house")
should return "Not Found"
.");'
```