. // tests completed
my code is : `function checkObj(obj, checkProp) {
// Only change code below this line
var myobj={
gift: “pony”,
pet:“kitten”,
bed: “sleigh”
};
if (myobj.hasOwnProperty(checkProp))
{
return myobj[checkProp];}
else {
return “Not found”;
}
}
checkObj(“gift”);
// Only change code above this line`
in the checkObj(obj, checkProp) in line 1 obj is dimmed and am I required to change the ‘obj’ in line 1 to ‘myobj’? if I do so still I cannot pass the test.
I have tried all the codes given in the hints, yet no passing. As I am newbie , I request for exact code to start below line 1 to pass the test. thanks.
In your code you have written ‘found’ in lowercase and it should be ‘Found’ !
In your code you have declared a new variable called ‘myobj’. That is not asked and superfluous! You should only use the variable ‘obj’ in the function.
remove also the last instruction ‘checkObj(“gift”);’
That means:
Remove the whole declaration of ‘myobj’ from your code and and replace it in your ‘if’ and 'return ’ with ‘obj’
I have just done those changes and your code runs perfectly!
Try it and if you have further questions do not hesitate to ask them!
thanks for guidance.
As suggested I changed my code to function checkObj(obj, checkProp) { // Only change code below this line if (obj.hasOwnProperty(checkProp)){ return obj[checkProp]; } else { return " Not Found"; } }
when I run the test the following message is given: // running tests checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house") should return "Not Found". checkObj({city: "Seattle"}, "district") should return "Not Found". // tests completed
the problem is that the test is not being passed. the same solution is given in the help video.
what and where I am missing , I fail to understand.
pl advise. thanks.