Testing Objects for properties.. New code issue

Tell us what’s happening:

Hey everyone,
I don’t know how to incorporate the Seattle code that was provided for this exercise. I haven’t seen anyone post with the Seattle code so my guess is that it is new to the code for this exercise?
Here’s how is how it reads:

checkObj({city: “Seattle”}, “city”) should return “Seattle” .

checkObj({city: “Seattle”}, “district”) should return “Not Found” .

how do I incorporate this into my current code. Thank you!

Your code so far


function checkObj(obj, checkProp) {
// Only change code below this line
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(obj, checkProp) {
if(obj.hasOwnProperty(checkProp)) {
  return obj[checkProp];
} else {
  return "Not Found";
}
}
return "Change Me!"

// 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/83.0.4103.97 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

You don’t need to inizialize myObj inside the function.

Not sure what you mean… can you show what the correction would be so I can physically see it? Thank you!

In your code above you wrote two functions checkObj.
One with the inizialitation of an object and one with the correct method to check if it has that property.
You have only to use the second one and forgot the first one.
As you wrote above without return 'Change me':

function checkObj(obj, checkProp) {
if(obj.hasOwnProperty(checkProp)) {
  return obj[checkProp];
} else {
  return "Not Found";
}


// Only change code above this line
}

That’s weird I tried it and it didn’t work.

If I copy and paste in the challenge, it tells me that s good!

function checkObj(obj, checkProp) {
if(obj.hasOwnProperty(checkProp)) {
return obj[checkProp];
} else {
return “Not Found”;
}

This is all you copy and pasted? I put that in and it didn’t work :\