Hi there. I am just curious as to why this code won’t work?
function checkObj(obj, checkProp) {
if (obj.hasOwnProperty(checkProp)) { // Check if obj has checkProp as a property
return checkProp; // Return checkProp if it exists
} else {
return "Not Found"; // Return "Not Found" if checkProp does not exist
}
}
Describe your issue in detail here.
Your code so far
function checkObj(obj, checkProp) {
// Only change code below this line
return "Change Me!";
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Testing Objects for Properties
Link to the challenge: