Basic JavaScript - Testing Objects for Properties

Tell us what’s happening:
I believe this is correct. Have had a few google searches as well, and still have no idea what is wrong with the code.

It throws up the warning below but none of this is even mentioned in the “Hints” or other questions. *warnings below
// running tests

checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift")

should return the string

pony
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet")

should return the string

kitten
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house")

should return the string

Not Found
checkObj({city: "Seattle"}, "city")

should return the string

Seattle
checkObj({city: "Seattle"}, "district")

should return the string

Not Found
checkObj({pet: "kitten", bed: "sleigh"}, "gift")

should return the string

Not Found

**Sorry for the weird formatting. It pasted it strange.

. // tests completed
Your code so far

function checkObj(obj, checkProp) {
  // Only change code below this line

  function checkObj(obj, checkProp) {
  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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Testing Objects for Properties

Link to the challenge:

Why did you put a function definition inside of a function definition here?

Too much time staring at the screen lol. Thank you :slight_smile:

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