Testing Objects for Properties with two parameter

** how to solve this questions **

   **Your code so far**

var obj = 
({gift: "pony", 
pet: "kitten", 
bed: "sleigh",
city: "Seattle"},
"gift","pet", "city")
function checkObj(obj, checkProp) {
 // Only change code below this line
 if (hasOwnProperty(checkProp)== checkObj)
 return "Change Me!";
 // Only change code above this line
   **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

Do you have a question? What is confusing you. It seems like you have gone down a wrong path - I might suggest using the Reset All Code button.

1 Like

I solved.

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

Cool, good job.

We don’t usually post solutions to challenges. If we do, we put them behind [spoiler][/spoiler] tags to hide them.

1 Like

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