Testing Objects for Properties

Help I’m stuck with this problem

Modify the function checkObj to test if an object passed to the function (obj) contains a specific property (checkProp). If the property is found, return that property’s value. If not, return “Not Found”.

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

  // Only change code above this line

Link to the challenge:

“checkProp” is a string and it should be the passed in parameter when calling hasOwnProperty.

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