Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
How I can get only active fields false items

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.

JsFiddle link is here

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>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!