Tell us what’s happening:
Hi guys, I was having problems completing this exercise.
I figured that if I added the property city: “Seatle” on top I could complete it.
If intended cool, if not then I have spotted this issue for future students
Thanks!
Here is my code
Your code so far
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(obj, checkProp) {
// Only change code below this line
if (myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
}
else {
return "Not Found";}
// Only change code above this line
}
checkObj(myObj, "gift");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.
Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.
FYI - The myObj variable was left over from a previous version of this challenge. I have created a pull request to remove it from the challenge seed code inorder to prevent confusion.
I’m not sure I understand your question. Do you mean how do you use both of the function parameters in the body of the function? You are already using one of them (checkProp):
if (myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
}
checkProp was passed into the function and represents the property name you want to check for in the object.
The issue with your code is that you are using the myObj object to make this check instead of the object passed into the function. So you just need to update your code to use the name of the object passed into the function (the first parameter) to make this check.