my scenario
1 - if I do click the button, I am filtering the array by active field as false, and then updating fields as true.
2 - if I do click second time, I want to get objects with only active fields false.
Result : All items are getting.
const test =[
{firstName:'abc',lastName:'abc',active:false},
{firstName:'def',lastName:'def',active:false},
{firstName:'ghi',lastName:'ghi',active:false},
]
document.getElementById('btn').addEventListener('click',()=>{
const test2 = test.filter(x=>x.active ===false);
console.log(test);
test2.forEach(x=>{
x.active=true;
})
})
<button id="btn">
Get
</button>