In my JavaScript code, I am working with an object structured like this:
Cards:Object
|->Pack:Object
|->Spades:Array[60]
|-> 0: Object
|-> Card_img: "www.test1.com"
Card_type:"9"
1:
|-> Card_img:"www.test2.com"
Card_type:"8"
I am trying to figure out how to loop through all the key-value properties in Spades {0, 1, etc} and return something like {card_img: www.test1.com, card_img: www.test2.com}
Here is the code snippet I have written:
Object.keys(cards).forEach(function (key) {
console.log(key); // This gives me 'Card', but how can I drill down further?
});
When I try
Object.keys(cards.Packs).forEach(function (key)
I get Object.keys called on non-object
.