Testing Object if available

Pls I need help here everytime I run the program it brings back what I’m expected to do.

   **Your code so far
var obj = {  
gift: "pony", 
pet: "kitten",
 bed: "sleigh" 
}
function checkObj(obj, checkProp) {
 // Only change code below this line
 if (obj.hasOwnProperty(checkProp)){
 return obj[checkProp];
 } else {return 'not Found';}
 // Only change code above this line
} 
obj.hasOwnProperty("gift");
obj.hasOwnProperty("pet");
c("bed");
checkObj("city");


   **Your browser information:**

User Agent is: Mozilla/5.0 (Android 10; Mobile; rv:88.0) Gecko/88.0 Firefox/88.0

Challenge: Testing Objects for Properties

Link to the challenge:

Which test cases aren’t passing?

First of all, get rid of the stuff after the function definition. It’s messing up the tests. Second, you are supposed to return “Not Found” if the property isn’t found. Third, you can get rid of the object you declared before the function definition as it’s not needed.

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