Hello FreeCodeCamper s
I’m trying to find a property inside my object with the hasOwnProperty() method, but when I pass the argument to the function, although I have declared
the object earlier to the function but its return Not Found
var obj = {
age : "29",
};
function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty(checkProp)){
return obj[checkProp];
}
return "Not Found";
// Only change code above this line
}
console.log(checkObj( "age"))
im sure that i have a mistake somewhere any Hint will be appreciated
First, you’ve got that global one you’ve defined, but second, look closely at that function. It takes two parameters and defines local variables for them: obj and checkProp.
With this, you’ve set your first parameter (obj) to “age”, and the second (checkProp) to undefined.