Basic JavaScript - Testing Objects for Properties

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

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

Challenge: Basic JavaScript - Testing Objects for Properties

Link to the challenge:

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

I’m not sure why the code isn’t passing. The tests says:

  • 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.

and I’m not sure how to add kitten, bed. sleigh, gift, seattle into the code.

You shouldn’t add those specific values.

Modify the function checkObj to test if the object passed to the function parameter obj contains the specific property passed to the function parameter checkProp.

You are ding this part here, but…

If the property passed to checkProp is found on obj, return that property’s value. If not, return Not Found.

Are you doing this?

Oh I need to add an if statement for that to work

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