Although I managed to get it to work, the perplexing part is trying to comprehend how this can occur!
This error message pops up: [ReferenceError: Property ‘date’ doesn’t exist]
for (const [date, items] of Object.entries(object)) { console.log(date) }
Now, check out this working version:
for (const entries of Object.entries(object)) {
const date = entries[0]
const items = entries[1]
console.log(date)
}
The object in question remains constant each time it runs. It strictly contains only one entry, here's a peek at its contents when logged using Object.entries(object):
[
"2022-01-02",
{
"a": [objects],
"b": object,
"c": [objects]
}
]
In the functioning code block, I can observe the logging of date. However, attempting to log date after restructuring results in an error. It seems like the issue stems from my attempt to destructure the array. But why does this happen? Just so you know, I'm currently working with React Native.