In this challenge, I kept given error for :-
Error
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift")
should return the string
pony
.
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet")
should return the string
kitten
.
checkObj({city: "Seattle"}, "city")
should return the string
Seattle
.
Code*
let myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh",
city: "Seattle"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)){
return myObj[checkProp];
}else{
return "Not Found";
}
}
checkObj("gift");
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36
.
Challenge: Testing Objects for Properties
Link to the challenge: