Testing Objects for Properties. Please Help

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

  1. checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift") should return the string pony .

  2. checkObj({pet: "kitten", bed: "sleigh"}, "gift") should return the string Not 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

You shouldn’t make this new object. You need to use the function argument.

1 Like

whew, thank you it worked

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.