Testing Objects for Properties - Help please

Tell us what’s happening:

I don’t understand why my code is false !

Your code so far


// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if(myObj.hasOwnProperty("gift"))
  return myObj["gift"];  
  if(myObj.hasOwnProperty("pet"))
  return myObj["pet"];  
  if(myObj.hasOwnProperty("bed"))  
  return myObj["bed"];
  else  
  return "Not found";
}
// Test your code by modifying these values
checkObj("gift");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties

You’ve hardcoded properties to test for, read what the challenge is asking you to test for (hint: you are passing an argument to the function but in your code you haven’t used it at all)

Ok thanks i get it but i don’t know how to translate it into code !

I got to use checkProp I think

Look at the values you have hard coded, and look at the example:

checkObj("gift");

The argument being passed in is checkProp

Ok i got it ! Thank you :slight_smile: