# Reading env vars Write a method to read configuration values from a configuration object based on a key Example of keys as input: ``` "profile.setting.showImage" "home.showAnalytics" ``` # Code ```javascript const get = (obj, path) => { if(obj !== null || typeof obj !== 'object') { return null; } if(!path) { return null; } const props = path.split('.'); let value = obj; for(let i = 0; i < props.length; i++) { const prop = props[i]; value = value[prop]; if(value === undefined) { value = null; break; } } return value; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up