How to determine whether an array object has a value, and then return the array of objects with this value. Because I'm a novice, I tried to write it, but I didn't, give an example:
const menu = [
{
title: "one",
children: [{name: "hello"}, {name: "bye"}],
},{
title: "two",
children: [{name: "good"}, {name: "bad"}],
},
]
Assume input "bad", the result should be:
menu = [
{
title: "two",
children: [{name: "good"}, {name: "bad"}],
}
]
How to do it?