Stuck with hasOwnProperty() method

Hello everyone,
please, could you check where is the mistake in this code?
var myObj = {
gift: “pony”,
pet: “kitten”,
bed: “sleigh”

function checkObj(checkProp) {
// Your Code Here
var result;
var check = myObj.hasOwnProperty(checkProp);
if (check === true) {
result = myObj.checkProp;
else {
result = “Not Found”;

return result;


only one line is off in your code; hint: review the “Access Objects Properties with Variables” exercise

done, thank you so much

I would suggest shorter two-line function code for those who are still looking for a solution:

function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp)) return myObj[checkProp];

return “Not Found”;

1 Like