Even if I copy solution of the task test fails.
The task does not match the built-in test settings.
Task:
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"
.
Result of test:
// running tests
checkObj({gift: “pony”, pet: “kitten”, bed: “sleigh”}, “house”)
should return the string
Not Found
checkObj({city: “Seattle”}, “district”)
should return the string
Not Found
checkObj({pet: “kitten”, bed: “sleigh”}, “gift”)
should return the string
Not Found
. // tests completed
**Your code so far**
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
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0
Challenge: Testing Objects for Properties
Link to the challenge: