Testing Objects for Properties problems with items1 and the last

Tell us what’s happening:
Describe your issue in detail here.
i have issues with the last point, that have to say “Not found” when pony is not.
but when i delete pony, the first item that have to say whats pony is… don’t pass…

   **Your code so far**

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

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

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

Challenge: Testing Objects for Properties

Link to the challenge:

Within your function, you shouldn’t know about myObj. Everything your function needs to know about is passed in as a parameter.

The test shown is an example, but other objects and properties will be passed in for testing.

sorry, i translate with google. but don’t understand…

ooowww ok. you mean that the function don’t know the name of the object?
so i just have to pass them like parameter?
is like that?

In your checkObj function, you’re using myObj. Don’t.

Instead, use the obj that gets passed in as a parameter:

checkObj(myObj, "gift");

i change but the web colpse when i do…

function checkObj(obj, checkProp) {
 // Only change code below this line
 if (myObj.hasOwnProperty(checkProp)) {     // you say that i have to change this line?
return myObj[checkProp];
} else {
return "Not Found";
}
// return "Change Me!";
 // Only change code above this line
}
checkObj("gift");

This shouldn’t show up anywhere inside of your code.

These are the two variables you have to work with.


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like

thanks, mate!!!
and sorry for my english… is to bad… is “spanglish”
i will keep trying

Your english seems fine to me.
Plus we have plenty of people on the forum where english is not their first language.

But if you wanted to go through these lessons in spanish, then the whole curriculum has been translated into spanish
Spanish curriculum

1 Like

thanks! :slight_smile: but i want to practice in english!!! :slight_smile:

I do!!! :slight_smile: thanks!!!

I do!!! :slight_smile: thanks for your help!!!