Сообщение от guerragro
|
подправил
|
let arr = [
{count: 3, emergency_count: 2, names: [{age: 15, name: "Вася"},{age: 19, name: "Петя"},{age: 20, name: "Олег"}]} ,
{count: 3, emergency_count: 2, names: [{age: 33, name: "Василий"},{age: 19, name: "Петя"},{age: 17, name: "Паша"}]},
{count: 3, emergency_count: 2, names: [{age: 55, name: "Олег"},{age: 15, name: "Ярослав"},{age: 35, name: "Игорь"}]}
]
const fn = (arr, str) => arr.filter(el => el.names.some(v => Object.values(v).includes(str)));
let ar = fn(arr, "Петя");
console.log(ar)