Basic JavaScript - Testing Objects for Properties

Tell us what’s happening:
Describe your issue in detail here.
Can one Explain or describe what I’m missing? I think its the returns are written wrong .
Your code so far

function checkObj(obj, checkProp) {
  // Only change code below this line
  checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift") 
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet")
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house")
  return "Not Found";
  
  checkObj({city: "Seattle"}, "city");

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

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

  // Only change code above this line
}

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Testing Objects for Properties

Link to the challenge:

What’s all this stuff? You shouldn’t be hardcoding objects. You need to use the function parameters obj and checkProp to determine if obj has the property checkProp

damn , i think i know what you mean . need like an example or elaboration

function checkForProperty(object, property) {
  return object.hasOwnProperty(property);
}

This function uses object and property.

1 Like

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