Created
February 9, 2019 08:36
-
-
Save afrieirham/80b81cf0adbee312042e618e0687111f to your computer and use it in GitHub Desktop.
Basic JavaScript: Testing Objects for Properties #FCC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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