what’s happening:
heyy
I’ve been working on this problem and have been able to provide 3 different solutions to be able to get all check, except the last one.
*checkObj({pet: “kitten”, bed: “sleigh”}, “gift”) should return the string Not Found .
is it requiring me to set up a “case” basis? ive done that and still same occurs.
any help is super appreciated!
**Your code so far**
function checkObj(obj, checkProp) {
// Only change code below this line
var obj = {
gift: "pony",
pet: "kitten",
bed: "sleigh",
city: "Seattle",
};
if (obj.hasOwnProperty(checkProp)) {
return obj[checkProp];
} else
return "Not Found";
}
checkObj("");
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36
Hi @rsmith90 how are you, the prob is that you have defined the var obj inside the function so it has a local scope meaning, it cannot be accessed outside the function, and additionally you haven’t passed the correct function arguments ( checkObj("") ) and lastly the function parameter obj has been defined as a variable, my suggestion would be… Removing the obj variable and inputting the correct arguments in the function call => i.e
function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty(checkProp)) {
return obj[checkProp];
} else
return "Not Found";
}
var object = {
gift: "pony",
pet: "kitten",
bed: "sleigh",
city: "Seattle",
};
checkObj(object,"pet");