function filter(arr, field, value) {
arr.filter((e) => e.field === value)
}
let result = filter(objects, 'name', 'Иван')
Не проверял) let objects = [
{ name: "Василий", surname: "Васильев" },
{ name: "Иван", surname: "Иванов" },
{ name: "Пётр", surname: "Петров" }
]
function filter(arr, key, value) {
return arr.filter(obj => obj[key] === value);
}
let result = filter(objects, "name", "Иван");
console.log(result)