"Dog" (an argument is not defined) SOLVED

I want to check if checkProp (dog) exists in obj (objThing) and that it returns checkProp (and if it doesn’t, to return “Not Found”), but it says that dog is not defined. Any idea as to why?

var objThing = {
  "dog": "Maxwell"
}

function checkObj(obj, checkProp) {
 if (obj[checkProp] !== undefined) {
    return obj[checkProp]
  } else {
    return "Not Found"
  }
}


checkObj(objThing, "dog")

Could it be that dog and "dog" are not the same? : )

Also, I think you want to be returning property rather than checkProp.

1 Like

dog is a variable (one that you have not defined). “dog” is a string. Property names are strings.

2 Likes