Having a problem with this one: Testing Objects for Properties

Tell us what’s happening:
If the property is found, return that property’s value.
But, the value should be checkProp since that seems the container that holds the value right? or what am i missing here?

Your code so far

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"

function checkObj(obj, checkProp) {
// Only change code below this line 
if checkObj.hasOwnProperty("checkProp"){
  return checkProp;
} else {
  return "Not Found";
// Only change code above this line

checkObj(myObj, "gift");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

You should use variables correctly. checkProp != "checkProp" .
Generally, you’re not treating arguments and variables correctly.

1 Like

if checkObj.hasOwnProperty("checkProp"){

  • There is no such thing as checkObj. This will cause an error.
  • You are not using you obj parameter.
  • You are not checking for the checkProp parameter.

A PR to remove the checkObj(myObj, "gift"); shown in the seed code was merged 2 hours ago. The fix should hopefully show up in production later today once it gets deployed.

1 Like