Basic JavaScript - Testing Objects for Properties

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

Your code so far

function checkObj(obj, checkProp) {
  // Only change code below this line
  return "Not Found";

checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift")//pony
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet")//kitten
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house")//Not Found
checkObj({city: "Seattle"}, "city")//Seattle
checkObj({city: "Seattle"}, "district") //Not Found
checkObj({pet: "kitten", bed: "sleigh"}, "gift")//Not Found
  // Only change code above this line

Your browser information:

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

Challenge: Basic JavaScript - Testing Objects for Properties

Link to the challenge:

Remember, anything you add after the return statement will not run since a return statement immediately exits the function. So all of those calls to checkObj below the return statement are doing nothing.

Also, you don’t want to call checkObj inside of checkObj. That is just going to cause an infinite loop.

Reread the instructions closely:

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

That sounds like it’s saying “if this do something, else do something else”. Hopefully that’s a big enough hint to get you going in the right direction.

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