Given this array I'm getting from an XHR request:
[
{
"dinnerID": "h1799-05-20a",
"date": "20 May 1799",
"note": "<note xmlns=\"http://www.tei-c.org/ns/1.0\"/>",
"diners": {
"name": [
[
{
"mentioned": null,
"slept": "no",
"cancelled": null,
"person": "Miss Caroline Fox"
}
],
[
{
"mentioned": null,
"slept": "no",
"cancelled": null,
"person": "Lady Lucy Anne FitzGerald"
}
],
[
{
"mentioned": null,
"slept": "no",
"cancelled": null,
"person": "Dr ??? Drew"
}
],
[
{
"mentioned": null,
"slept": "no",
"cancelled": null,
"person": "Lady Elizabeth Vassall-Fox"
}
],
[
{
"mentioned": null,
"slept": "no",
"cancelled": null,
"person": "Lord Richard Vassall-Fox"
}
]
]
}
}
{
"dinnerID": "h1799-05-21a",
"date": "21 May 1799",
}
]
how do I get a list of the names (person), and also use the other mentioend, slept, and cancelled?
This:
for (var dinner of result) {
let diners = dinner.diners.name.person.join(", ")
}
returns a Uncaught TypeError: dinner.diners.name.person is undefined error. I'd like to return something like
Miss Caroline Fox (slept)(mentioned)(cancelled), Lady Lucy Anne FitzGerald (slept)(mentioned)(cancelled) etc.
I'm attaching a screenshot of my console.log(result).

dinner.diners.nameis a 2-dimensional array. You need to loop through it.dinner.diners.name.forEach((name) => name.person)[not{