Tell us what’s happening:
Describe your issue in detail here.
so I’m not sure what I’m doing wrong.
Your code so far
function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty(checkProp)) {
return obj[checkProp];
} else {
return "Not Found";
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Testing Objects for Properties
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift") should return the string pony .
is what i’m failing but im confused because it doesn’t ask me to input an object and when I do i get the same test wrong.
Tell us what’s happening:
Describe your issue in detail here.
I’m getting the error checkObj({pet: "kitten", bed: "sleigh"}, "gift") should return the string Not Found . Your code so far
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh",
city: "Seattle"
};
function checkObj(obj, checkProp) {
// Only change code below this line
var answer = "Not Found";
if (myObj.hasOwnProperty(checkProp)) {
answer= myObj[checkProp];
}
return answer;
// Only change code above this line
}
checkObj("gift");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Testing Objects for Properties
Please remove the top part where you declare myObj. Also remove the bottom part checkObj(“gift”). You need to change code only in between the lines suggested.
Also the function’s parameter is ‘obj’. But in your code you are working on ‘myObj’. So you are not referring to the same object here. Pls fix the names. Thats it!
Tell us what’s happening:
Describe your issue in detail here.
ok I changed what I was told to change, but I’m still getting the same error. Your code so far
function checkObj(obj, checkProp) {
// Only change code below this line
var Obj = {
gift: "pony",
pet: "kitten",
bed: "sleigh",
city: "Seattle",
};
var answer = "Not Found";
if (Obj.hasOwnProperty(checkProp)) {
answer= Obj[checkProp];
}
return answer;
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Testing Objects for Properties