FCC: Testing Objects for Properties

Instructions:

Modify the function checkObj to test myObj for checkProp. If the property is found, return that property’s value. If not, return "Not Found".

Solution: 

screen-shot-2017-01-11-at-10-27-40-pm

Notes:

  • .hasOwnProperty(propname)method of objects to determine if that object has the given property name.
  • .hasOwnProperty()returnstrueorfalseif the property is found or not.
  • use ‘===’ to check for true or false.
  • To return value of a property in a lookup table:  lookupTable[property];
Advertisements
FCC: Testing Objects for Properties

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s