const data3 = [
{ name: "Андрей", age: 31 },
{ name: "Валерия", age: 31 },
{ name: "Егор", age: 25 },
{ name: "София", age: 29 },
{ name: "Антон", age: 40 },
];
data3.forEach((item, index)=>{
let maxAge = Math.max(...data3.map((n) => n.age));
if(item.age == maxAge){
data3.splice(index,1)
}
console.log(item)
});