Stuck @ Basic JavaScript: Testing Objects for Properties

Can anyone tell me where i went wrong? Stuck!
Tell us what’s happening:

Your code so far


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

function checkObj(obj,checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
}
else 
return "Not Found";

}

// Test your code by modifying these values

console.log(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift"));

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

Hi,

In the function you have “obj” as a parameter. So you have to use it and not myObj!

2 Likes

Thankyou so much buddy, It’s working now! @moriel :slightly_smiling_face:

1 Like

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