Tell us what’s happening:
Describe your issue in detail here.
I don´t know what return’s this function, maybe propname or checkname
**Your code so far**
function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty(checkProp)) {
return propname}
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/104.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Testing Objects for Properties
If the property is found, return that property’s value.
You have
return propname
What is “propname”, there is no variable with that name.
You have the the object, and you have the property name (in a different variable, you just checked for it). Use that property name to get the value and return that.
Also, you would do yourself a favor to learn to format code as you go - it will save you a lot of trouble in the long run. Well formatted code is a lot easier to debug.