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
var result = "";
var myObj = {
  "gift": "pony",
  "pet": "Kitten",
  "house": "Not Found",
  "city": "Seattle",
  "district": "Not Found"
};
function checkObj(checkProp) {
 myObj.hasOwnProperty(checkProp);
 return myObj[checkProp] || "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/117.0.0.0 Safari/537.36 Edg/117.0.2045.60

Challenge: Basic JavaScript - Testing Objects for Properties

Link to the challenge:

You altered and added things you were not asked to.

  1. The object is passed to the function, you do not create it. Do not change the original function signature.

  2. The nested function you created is never called because the test will only invoke the outer function. Do not create nested functions.

This is the starting function.

function checkObj(obj, checkProp) {
  // Only change code below this line
  return "Change Me!";
  // Only change code above this line
}

Add the code logic inside that function, using the obj parameter as the object and the checkProp parameter as the property you check for.


Do not use random code you find. If you must use a solution, use one of the solutions from the hint page.

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