Issue with "Testing Objects for Properties" accepting my code

I have tried to submit my code and I keep getting errors when submitting. Can someone tell me where the error is?

function checkObj(obj, checkProp) {
  // Only change code below this line
 var myObj ={
    gift: "pony",
    pet: "kitten",
    bed: "sleigh"

  function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp)) {
  return myObj[checkProp];
} else {
  return "Not Found";
  // Only change code above this line


   **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

It looks like you are declaring a new function inside of the original function. You definitely don’t want to do that. You also do not need to create the myObj object inside of the function. The object you will check is passed into the function in the first parameter named obj.


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

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