I'm trying to iterate over a nested object in Javascript and have the iterator return the sub-objects.
Here's the test data:
const testData = {
item1: {
name: "test",
time: "now",
},
item2: {
name: "other",
time: "then",
},
};
I'd like to do something like the following pseudocode with it:
for (var item in testData) {
console.log(item.name);
console.log(item.time);
};
which I want to have output:
"test"
"now"
"other"
"then"
Unfortunately, as simple as this feels like it ought to be, it seems to run afoul of type-related things going on in Javascript, and I'm quite at a loss as to how to handle it. How do I translate the above pseudocode for loop into functional Javascript?