Missing set up for checkObj problem

I believe the var myObj is meant to be in the setup for this problem, but is not there. I don’t need help, I checked the test requirements to see what objects should be in the variable and create it myself, but I have a feeling this is not how the problem is supposed to be setup.

  **Your code so far**

function checkObj(obj, checkProp) {
// Only change code below this line
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh",
city: "Seattle"
};
return ;
// Only change code above this line
}
  **Your browser information:**

User Agent is: Mozilla/5.0 (Linux; Android 11; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.115 Mobile Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

You should not define an object inside of your function. The object is passed in as the function argument obj.

1 Like

Well yes, but I am not supposed to change the code outside of the comments and there is no variable in the setup… This is why I think the lesson is broken. From what I see in other people’s forum posts the var myObj is defined in the set up.

myObj, which might be passed in by a test, like so:

const myObj = {
  name: "foo",
  horse: "roan",
  favoriteColor: "red...no BLUE!"
}

console.log(checkObj(myObj, favoriteColor) );

in this, the myObj is defined outside your function, and your function should never know about it. The only thing checkObj should know is the obj parameter.

1 Like

There is an old version of the challenge that was designed to only work for that specific object, but it is a very inflexible design so we changed the challenge. We’ve changed challenges enough that looking other people’s solutions on the forum can be confusing.

1 Like

So we are required to create our own variable outside of where the comments state we should edit the code? Since everything we are allowed to change is within the function.

You have obj and you have checkProperty. That is everything your function needs to see if obj contains a property named checkProperty.

The tests themselves are automated, you don’t create or edit them in any way.

1 Like

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