Stuck on Testing Objects for Properties

Stuck on Testing Objects for Properties
0

#1

Okay I was confident at first about this question but now I don’t know what I did wrong. Not sure if I’m even meant to add a if statement.


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

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
    return checkProp;
  } else {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("gift");

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


#2

instead of returning the name of the property, you should return the property’s value
(so if the property was ‘gift’ for eg. your output would be ‘pony’)


#3
return checkProp;

You are returning the same value that was passed in. Are you meant to be returning the object’s property?


#4

Okay this is what I done but I am getting no response back from the program

return myObj.checkProp;


#5

wait never mind I changed it to a bracket notation and it worked