I have button that I’m disabling by reading an array and checking its properties.
My array looks like this:
const arr = [
{id: ‘1’, name: ‘SOME_THING’, status: ‘AGREED’},
{id: ‘2’, name: ‘THIS_THING’, status: ‘AGREED’},
{id: ‘3’, name: ‘OTHER_THING’, status: ‘AGREED’},
{id: ‘4’, name: ‘EVERY_THING’, status: ‘AGREED’},
];
My current logic to disable/enable this button looks like this:
arr.filter((item) => item.indexOf(‘THING’) > -1)
.every((item) => item.status === ‘AGREED’)
Now my requirements have changed. I want to enable/disable the button in the same way, but I want to EXCLUDE specific elements from this array. For example, I want to exclude these two items:
{id: ‘2’, name: ‘THIS_THING’, status: ‘AGREED’},
{id: ‘3’, name: ‘OTHER_THING’, status: ‘AGREED’},
Using my logic, how do I filter my array while EXCLUDING these two?
I realize I can just try to delete these specific items but I was wondering if there was potentially a cleaner way to do that without explicit deletion.