P粉6198961452023-09-05 10:42:18
You should use some(), not every().
const bool = arr.map(group => group.values.some(val => val.id)).filter(bool => !bool).toString();
every() method is used to check whether all elements in the array meet the given conditions. array. The some() method is used to check whether at least one element in the array meets the given condition.
P粉3365367062023-09-05 10:07:13
That's because your algorithm is incorrect. The every
method will check if all objects have an id, but that's not what you want, right?
So try this
const bool = arr.map(group => group.values.some(val => val.id));