Possible bug? Testing Objects for Properties

Tell us what’s happening:
Describe your issue in detail here.
my code is not working as it does not comply with the last required taskbar element, namely: checkObj({pet: "kitten", bed: "sleigh"}, "gift") should return the string Not Found .
I don’t understand how to declare this result as ‘Not Found’ when these properties are necessary to solve former taskbar elements. This is the last requirement before the code runs smoothly.
I have not found any other info as a past thread on this challenge seems irrelevant as it does not mention the myObj properties while the Hint does not provide an adequate solution.

  **Your code so far**

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

function checkObj(obj, checkProp) {
// Only change code below this line
return myObj[checkProp];
else {
return "Not Found"
// Test your code by modifying these values
// 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/96.0.4664.110 Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

    return myObj[checkProp];

Here you are referring to the global variable myObj instead of using the object that was passed into your function.

This means that the tests cannot pass in specific objects to test.

Be sure to read instructions closely:

Modify the function checkObj to test if an object passed to the function ( obj ) contain … [emphasis added]

Paying attention to tiny details is an important part of being a developer.

When I fix that, your code passes for me.

1 Like

noted with thanks. Personally, I found this challenge was very confusing! I have completed it though

Yeah, some of them get a little confusing. But so do design specs sometimes.

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