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

202
Views
JS update the value of the filtered object using array.filter

So I need to perform two actions 1) filter my array and 2) update the unfiltered values. currently, I am doing it this way and it works fine.

let installData = state.installData.filter((item) => {
        return item.sensor !== action.data.sensor;
      });

      installData = installData.map((item) => {
        return { ...item, asOfDate: false };
      });

however, I am doing operations here and was wondering if there is a more efficient way to update the value of my item directly inside the filtred method without having to use map

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe you could just use reduce and combine operations into a single function

 let installData = state.installData.reduce((acc,item) => {
     if (item.sensor !== action.data.sensor) acc.push({...item, asOfDate: false});
     return acc;
  },[]);
about 4 years ago · Juan Pablo Isaza Report
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!