I have written this code more than one way and I am not sure what to do from here to complete it

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
 var myObj = {
   gift: "pony",
   pet: "ktten",
   bed: "sleigh",
   city: "Seattle"
function myObj(obj, checkProp) {
 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/97.0.4692.71 Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

Hello, you have the solution already in this code, however it is impossible to access it.

The test will be attempting to run the function with the name of checkObj(). It will pass in an object much likes what you created with var myObj, along with a string that sometimes matches a property on that object and sometimes does not.

Inside of the checkObj() function, you have created a variable that does not get called anywhere and also shares the name of a function defined. You should try and avoid that.

The code inside of your myObj() function would pass the tests, however it does not get executed because it is not being called anywhere. One solution could be to return the function that you created, passing in the same arguments as above. There is a much cleaner way though.

Hope this helps without giving you the answer outright. You are very close though.

1 Like

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