Help :( "Testin Objects for Properties" help anyone

i couldn’t find the wrong code… :frowning:
can anyone help, thanks a lot before

   **Your code so far**

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh",
city: "Seattle",

function checkObj(obj, checkProp) {
 // Only change code below this line
 if(obj === myObj){
   return "Not Found";
else if (myObj.hasOwnProperty(checkProp)){
  return myObj[checkProp];
  return "Not Found";
 // Only change code above this line
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

You shouldn’t have myObj in this code at all. Only obj.

after i changed it, it still doesn’t work :frowning:

if (obj){
return "Not Found";

Why do you have this if clause?

If there is an obj, then return Not Found?

its because of the challenge ask for this :

checkObj({pet: "kitten", bed: "sleigh"}, "gift") should return the string Not Found .

so i created strict if conditions if one of the keys/ properties doesn’t exist in the object

But that if statement checks if obj exists, not if obj has the checkProp

1 Like

Thanks a lot, i understand the logic now
i changed it to this

    return "Not Found";
1 Like

Did you find the solution to this problem? Nothing seems to be working.

If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

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