I'd like please to retrieve all text (text 1,text 2....) from the following array :
[
{
"reviews":
[
{
"_id": "5e84239d6e24358b50f3fe4e",
"text": "My text 1"
},
{
"_id": "5e8423a46e24358b50f3fe4f",
"text": "My text 2"
}
]
},
{
"reviews":
[
{
"_id": "5e84239d6e24358b50f3fe4e",
"text": "My text 3"
},
{
"_id": "5e8423a46e24358b50f3fe4f",
"text": "My text 4"
}
]
},
{
"reviews":
[
{
"_id": "5e84239d6e24358b50f3fe4e",
"text": "My text 5"
},
{
"_id": "5e8423a46e24358b50f3fe4f",
"text": "My text 6"
}
]
}
]
This array is stored in a variable called stores.
I have tried the following :
const listText = stores.map(count => count.reviews.text // [null, null, null]
const listText = stores.map((count, i) => count.reviews[i].text) // Cannot read property 'text' of undefined
const listText = stores.forEach((key, i) => key.reviews[i].text) // Cannot read property 'text' of undefined
Could you please help me out here, Many thanks