arrayOfElements.map((element) => {
return {...element, subElements: element.subElements.filter((subElement) => subElement.surname === 1)}
})
let output = fruitData.filter(eachVal => {
let opt = eachVal.details.some((
{ gradingDetails }) => gradingDetails
.some(({ grade }) => grade === 'A'));
return opt;
})
console.log(output);
document.getElementById("Output").innerHTML =
JSON.stringify(output);