How do I console.log out the return or result of this code? Thanks in advance to everyone who replies to my question

Tell us what’s happening:
Describe your issue in detail here.

   **Your code so far**
function checkObj(obj, checkProp) { 
 // Only change code below this line
 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15

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.

Learning to describe problems is hard, but it is an important part of learning how to code.

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

1 Like

You can use the test cases to console log. They’re comprehensive and cover the important parts of the challenge (in this one, if the function works for an object that has the property and if it works for one that doesn’t have the property).

Some of the other challenges have additional code that affects the result. In this case, all you have is a function. You need to pass arguments into the function to see a result.

1 Like

Wrap the function call inside a console log.

console.log(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift")); // pony

As said, you can look at the tests on the left to see which arguments are passed to the function for the different tests.

Can you please explain why do I need the curly braces wrapped around the properties as part of the argument? Thanks again for your reply.

you are sending an object to the function as an argument, you know an object can be defined in between two curly braces having properties

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