I know. My question was if there was anything in the code I had written that would give a true value from obj.hasOwnProperty(checkProp), due to their being nothing in the code I wrote that assigns checkProp into obj.
Once again not could I provide input that could place checkProp in obj, but if or not it was already somehow placed inside it.
That question doesn’t make sense though. obj.hasOwnProperty(checkProp) only can be evaluated after obj and checkProp have values. Its neither true nor false until then.
Okay, that’s all I was trying to ask. I just wanted to know if the test was trying to get me to return a true value from obj.hasOwnProperty(checkProp), or write code that could do so with the right argument.
Just to be clear, when you define a function parameter, it is just a placeholder, a label to put on whatever is passed. It doesn’t know what will be passed. For example, this function could have been written:
function checkObj(abrahamLincoln, elephantPajamas) {
// Only change code below this line
if (abrahamLincoln.hasOwnProperty(elephantPajamas)) {
return abrahamLincoln[elephantPajamas];
} else {
return "Not Found";
}
// Only change code above this line
}
JS can’t read English. It doesn’t know what those mean. And it doesn’t know what it is getting passed. It doesn’t even know what type it is since JS stores types on the value, not the variable. So, it will just get sent a value (for primitives) or a reference (for reference types) and it will store them in those variable names. And then the function can do what it wants with them.