Test for a specific property of object

Unable to pass test object properties :
I need someone to run me through ,
I am finding it difficult to complete the bellow code using the object and the property’s declared as an argument within the function.

   **Your code so far**

function checkObj(obj, checkProp) {
 // Only change code below this line
({obj:"checkProp"}, "obj");
 if(obj.hasOwnProperty("checkProp")){
 return obj[checkProp];
 }
 else{
   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/99.0.4844.84 Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

What is this line?

This is checking for the property named “checkProp” instead for the property with the name stored in the checkProp variable.

Based on my understanding of the question.
"obj " is Object and CheckProp is the property of Obj .So, the line you are pointing to is initialization.

Ok… but what do you think that line is doing

It is an assignment that assigning checkProp to the obj

There is no =, so it cannot be an assignment.

And you shouldn’t ‘assign’ checkProp to the object. You shouldn’t change obj in any way.

“obj” is acting as the value and “CheckProp” is properties.
therefore, obj is acting as a container for CheckProp

No. I don’t understand what you are trying to do, but it is not at all needed or correct.

That line isn’t doing anything, but whatever you are trying to do with that line is not needed. That line should be deleted.

Thanks,
After deleting the line the code is not yet perfect .How do I go about the rest? I have been struggling with this since yesterday and I have done all the magic

Did you see this part of my first post? Have you made any changes based upon this comment?

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