I hat happens to my code i can't pass my challenge?

Tell us what’s happening:

Your code so far


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

function checkObj(checkProp) {
 // Your Code Here
if(myObj.hasOwnProperty("checkProp")){
 return myObj[checkProp]
}
else{
 return "not found"
}
 
}
console.log(checkObj("gift"))


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.4068.4 Safari/537.36.

Challenge: Testing Objects for Properties

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

You’ve got a couple sticking points in your code here!

Remember that when passing an argument into a function you should treat it like a variable. So:
myObj.hasOwnProperty("checkProp")
should be
myObj.hasOwnProperty(checkProp)

also remember to pass the tests, you’ll want to match the exact casing the directions tell you to provide for each result. (hint: “not found” probably is missing one or more capital letters).

1 Like

Thank you it works,now