Javascript:Testing Objects for Properties`

Hi,
Still stuck with this one let try with this,

// Setup

var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  var propname;
if(myObj.hasOwnProperty(checkProp)== true){
  return myObj[checkProp];
}
  else{
    return "Not Found";
  }
}


// Test your code by modifying these values
checkObj("gift");
1 Like