Testing Objects for Properties
Summary
.hasOwnProperty(propname)is used to check of a object has a specific property.- Returns
trueorfalse.
Final Code
function checkObj(obj, checkProp) {
// Only change code below this line
if(obj.hasOwnProperty(checkProp)) {
return obj[checkProp];
} else {
return "Not Found";
}
// Only change code above this line
}