Testing Objects for Properties unable to return "Not Found"

Hello,
I am stuck on the following 2 objects returning “Not Found”
I have to imagine there is a simple solution here, but as a I am new to this, I really have no idea how to return “House” and “District” as “Not Found”

The 2 tests that have failed are:

  1. checkObj({gift: “pony”, pet: “kitten”, bed: “sleigh”}, “house”)` should return “Not Found” .
  2. checkObj({city: “Seattle”}, “district”) should return “Not Found”.

Any help would be appreciated.
Thank you!

function checkObj(obj, checkProp) {
  // Only change code below this line
  var checkObj = {
    gift: "pony",
    pet: "kitten",
    bed: "sleigh",
    city: "Seattle"
  };
  if(checkObj.hasOwnProperty(checkProp)) {
    return obj[checkProp];
  } else {
    return "Not found";
  }
  // Only change code above this line
}

it looks like you pasted a hardcoded object into your function. You should use the obj passed in instead.


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

Thank you for the edit!
Will do next time…
The solution was a capital “F” in the “Not found” string.
Gotta match those strings in the examples.
Thanks again!