Skip to content

Instantly share code, notes, and snippets.

@Jagathishrex
Last active January 5, 2021 16:44
Show Gist options
  • Save Jagathishrex/17997fa902426ad10da78bea1290ec03 to your computer and use it in GitHub Desktop.
Save Jagathishrex/17997fa902426ad10da78bea1290ec03 to your computer and use it in GitHub Desktop.
// print key-values of an object recursively
function flattenObject(obj) {
for (let key in obj) {
if (typeof obj[key] === 'string') {
console.log(key, obj[key]);
}
if (typeof obj[key] === 'object') {
flattenObject(obj[key]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment