Skip to content

Instantly share code, notes, and snippets.

@afrieirham
Created February 9, 2019 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afrieirham/80b81cf0adbee312042e618e0687111f to your computer and use it in GitHub Desktop.
Save afrieirham/80b81cf0adbee312042e618e0687111f to your computer and use it in GitHub Desktop.
Basic JavaScript: Testing Objects for Properties #FCC
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
//Check if the Object has that property, not check the value.
if(myObj.hasOwnProperty(checkProp)){
return myObj[checkProp];
}
return "Not Found" ;
}
// Test your code by modifying these values
checkObj("gift");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment