Can't do Testing Objects for Properties

So I’m trying to go back over the lessons to do the record collection lesson. I’m stuck on this one, I don’t understand how else to solve it other than what I am doing already.

function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty(checkProp)){
  return obj;
return "Change Me!";
// Only change code above this line
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:101.0) Gecko/20100101 Firefox/101.0

Challenge: Testing Objects for Properties

Link to the challenge:

What are you asked to return?

The value but I see no way to do that. there is no declared value to return.

If the property is found, return that property’s value.

which value are you asked to return?

The properties value but I don’t know how. There is no object to get values from the properties.

What is obj?

If there is no object, what are you testing here?

1 Like

Nothing. Which doesn’t make sense because otherwise there isn’t anything to learn. I don’t understand how to test something that doesn’t exist.

Where does it say that obj means nothing?

Modify the function checkObj to test if an object passed to the function (obj) contains a specific property (checkProp)

its a function according to the lesson. But I don’t know what to do with that information.

Are you familiar with the concept of passing values to a function?

it’s “an object passed to the function”

No. obj is not a function

test if an object passed to the function (obj)

Oh sorry I misread. I still don’t know how to return the value.

I don’t know how to get a value when there are no objects to test.

Why do you keep saying this?!?

obj is an object

I’m missing something here about what you’re missing!

I thought an object needed things inside it?

like this is an object. it has things inside it.

const myDog = {
  "name": "Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["freeCodeCamp Campers"]

Obj has no things inside it so how do I get the value of it when there is nothing inside it?

The object is set up outside of the function call. You only need to know that obj is an object that may or may not have the property with the name stored in the variable checkProp.

Are you familiar with the concept of a variable?


I’ve done this lesson but don’t understand it or why it works. it does something but I don’t know what it means.