Details on Testing object por property

Tell us what’s happening:

  **Your code so far**

function checkObj(obj, checkProp) {
// Only change code below this line
if (checkObj.hasOwnProperty("checkProp"));

return "Change Me!";
// 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/88.0.4324.146 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.

1 Like

Hi @farhantanvir235 !

You started down the right path.
Your task is to check if obj has a property of checkProp.

In your code here

you were checking if checkObj has a property of checkProp.
CheckObj is the name of the function. Not the parameter.

Also checkProp should not be in quotes.

Once you fix that logic, then you need to address the return statement.

If obj has a property of checkProp then you need to return obj’s property value.

Remember you can access a prop’s value with bracket notation.

If the property is not found, then you need to return Not Found.

Hope that makes sense!

My apologies, I am new to the forum. I will remove my section of code, thanks for the reply!

  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

no, you don’t, none of those is ever referenced inside the function. This challenge doesn’t need any new object.

in this case, the object obj is not accessible from inside the function as it has the same name as the parameter. You don’t need to create any object to complete this challenge.

Thanks for the help. I tried the solution again without the object and it passed the test.