So this challenge was a bit tricky because the example given was set up differently. At first it looked like I needed to change the function into a var or create an object with key:value given the names in the code tests module. It wasn’t until I watched the video that the explanation made sense.
Source:
MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
Set up:
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"
.
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
}