我遇到了一个任务问题。如何使我的代码工作?
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkObj) === true) {
return myObj[checkObj];
} else return "Not Found";
}
myObj.hasOwnProperty("");
// Test your code by modifying these values
checkObj("gift");
答案 0 :(得分:3)
检查您的变量名称
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here vv HERE vv
if (myObj.hasOwnProperty(checkProp) === true) {
return myObj[checkProp]; // <= and here
} else return "Not Found";
}
myObj.hasOwnProperty("");
// Test your code by modifying these values
checkObj("gift");