Not sure where the mess up is

Tell us what’s happening:
I followed the solutions page and several other post’s code to troubleshoot my own and I am not sure why it is not taking? Any suggestions? Thanks in advanced!

  **Your code so far**

function checkObj(obj, checkProp) {
// Only change code below this line
myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh",
city: "Seattle",
if (myObj.hasOwnProperty(checkProp)) 
{return myObj[checkProp];}
else {return "Not Found";}

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36 Edg/90.0.818.46.

Challenge: Testing Objects for Properties

Link to the challenge:

Two things here:

  1. You need to add these closing brackets to the end of the function or else you’ll get an error: }
  2. The code you have written tests if the property passed into the function is inside myObj. However you shouldn’t create any object, but simply check wether the object from the function input has the given property or not.

You are almost there. The object myObj is already created by FCC and used to test whether your function works. Don’t hardcode it into your function! Modify your code a tiny bit and you’ll be there.

Using proper indentation helps catch issues with unmatched braces.

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