I don't understand this javascript question

Modify the function checkObj to test if an object passed to the function ( obj ) contains a specific property ( checkProp ). If the property is found, return that property’s value. If not, return "Not Found" . I sincerely don’t understand what to do.

function checkObj(obj, checkProp) {
var checkProp = {
“House”: “Pink”,
“Church”: “Blue”,
“Mosque”: “Purple”,
“Market”: “Yellow”
};
if (obj === checkProp) {
return “House”;
} else {
return “Not Found”;
}
obj.hasOwnProperty(“House”);
obj.hasOwnProperty(“middle”);
}
console.log(checkObj());





      **Your browser information:**

User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43</code>

**Challenge:**  Testing Objects for Properties

**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties

In previous challenges you learnt about objects. You have learned that objects consist of properties, which are key and value pairs. You also learnt how to access these properties and how to change them. Here you are asked to write a function which checks whether an object passed to the function has a specific property and if so to return its value, otherwise if that property doesn’t exist, return NOT FOUND . Hope this helps.

1 Like