Hi, I’m currently figuring out the logic behind this particular challenge.
I want to know why this code works, meaning it will return a “Not Found” since there’s no somethingElse…
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp) === true) {
return myObj[checkProp];
} else {
return "Not Found";
}
}
// Test your code by modifying these values
checkObj("somethingElse");
While this doesn’t return “Not Found” and instead shows a blank screen in the terminal.
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty(checkProp);
if (true) {
return myObj[checkProp];
} else {
return "Not Found";
}
}
// Test your code by modifying these values
checkObj("somethingElse");
Thanks!