My goal is to get the the text in the nested object translations where the field === “name” and the lang is “it” or “en” based on a variable i am passing. Below is the complete object.
{
"id": 231,
"name": "Titolo",
"pdf_url": null,
"translations": [
{
"field": "name",
"lang": "it",
"text": "POLITICA ANTI CORRUZIONE"
},
{
"field": "name",
"lang": "en",
"text": "ANTI CORRUPTION POLICY"
},
{
"field": "pdf_url",
"lang": "it",
},
{
"field": "pdf_url",
"lang": "en",
}
]
}
But the code below is not working.
document?.translations?.find(el => el?.field === 'name' & el?.lang === editLang)?.text