why can’t we use the dot notation inside a function using it’s parameters?
Your code so far
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)) {
return myObj.checkProp;
} else {
return "Not Found";
}
return "Change Me!";
}
// Test your code by modifying these values
checkObj("gift");
instead the of returning the property’s name it is returning undefined, I would also like to know why it’s doing that.
thank you.
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties