function checkObj(obj, checkProp) {
  if (obj.hasOwnProperty(checkProp)) {
    return obj.checkProp;
  }
  return 'Not Found';
}
console.log(checkObj({ gift: 'pony', pet: 'kitten', bed: 'sleigh' }, 'gift'));The code above gives an output of underfined whereas it works perfectly fine if it's
 return obj[checkProp]
Why does this happen? Thanks.
 
    