Created
April 13, 2015 06:45
-
-
Save timgws/faf641c10a437d9a396c to your computer and use it in GitHub Desktop.
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
var myObj = { | |
fred: { apples: 2, oranges: 4, bananas: 7, melons: 0 }, | |
mary: { apples: 0, oranges: 10, bananas: 0, melons: 0 }, | |
sarah: { apples: 0, oranges: 0, bananas: 0, melons: 5 } | |
} | |
var countMe = {} | |
var obj = 0; | |
var key; | |
var a = myObj; | |
for (key in a) { | |
subitem = 0; | |
if (a.hasOwnProperty(key)) { | |
for (item in a[key]) { | |
countMe[obj + "" + subitem] = a[key][item]; subitem++; | |
} | |
} | |
obj++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment