Skip to content

Instantly share code, notes, and snippets.

@robmint
Last active December 7, 2015 00:42
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 robmint/7d97d612c344626b2ce2 to your computer and use it in GitHub Desktop.
Save robmint/7d97d612c344626b2ce2 to your computer and use it in GitHub Desktop.
iterating through hash of lists in javascript
data = {
subject: ['Medical Science', 'Philosophy'],
year: ['2015', '2013']
};
for (key in data) {
if (data.hasOwnProperty(key) && data[key] instanceof Array) {
list = data[key];
list.forEach(function (value) {
console.log(key + " : " + value);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment