Problem with task "Testing Objects for Properties"

Even if I copy solution of the task test fails.
The task does not match the built-in test settings.

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:

You copied the answer wrong. That tends to happen when people copy the answer.

If not, return "Not Found" .

Your return value is wrong.

In general, I recommend against copying answers. Using someone else’s code is a useful skill, but it is not help you learn how to write code.

Yes, right. Result of test confused me when I try do it by myself

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.