Hello guys, please view the code i wrote:
I have to pass both tests below, how do i write the code to achieve this as i have only succeeded in passing the first test
-
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift")
should return the stringpony
. -
checkObj({pet: "kitten", bed: "sleigh"}, "gift")
should return the stringNot Found
.**Your code so far**
function checkObj(obj, checkProp) {
// Only change code below this line
var obj = {
"gift": "pony",
"pet": "kitten",
"bed": "sleigh",
"city": "Seattle"
};
if (obj.hasOwnProperty(checkProp)) {
return obj[checkProp];
} else {
return "Not Found";
}
// Only change code above this line
}