help please, i have this array of object and must to create a new array that contains all the objects from the original array of object that have a numerical value greater than 15. how can i do this ? which method a must to use ?
const names = [
{ name: 'Anna' },
{ num: 27 },
{ name: 'Valeria', age: 20},
{ secondname: 'Wilson' },
{ age: 12, name: 'Max' },
{ weight:'50kg', height: '172cm', name: 'Nick' }
]
i try to use filter,but it should see any field that has a number value not just age or num
const number = arr.filter(a => a.num || a.age > 15);
console.log(number);