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

182
Views
How to edit an item from my Reducer Objec based only with the ID?

I have a Reducer like this :

clientData : {
1080 : [{ID : 1111,name : 'John'},{ID : 2222,name : 'Stan'},],
1090 : [{ID : 3333,name : 'Adam'},{ID : 4444,name : 'Alan'},]
}

And I want to be able to edit the 444 Id's element like this :

{ID : 4444,name : 'New Value'}

So the output should look like :

clientData : {
1080 : [{ID : 1111,name : 'John'},{ID : 2222,name : 'Stan'},],
1090 : [{ID : 3333,name : 'Adam'},{ID : 4444,name : 'New Value'},]
}

Have you an idea please how to achieve it ? thank you

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

0

you can try it :

const clientData = {
  1080 : [{ID : 1111,name : 'John'},{ID : 2222,name : 'Stan'},],
  1090 : [{ID : 3333,name : 'Adam'},{ID : 4444,name : 'Alan'},]
}
Object.values(clientData).forEach(ele => {
  let a = ele.find(el => el.ID === 4444)
  if (a) a.name = 'new value'
})
console.log(clientData)

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!