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

189
Views
Cómo convertir res a Me gusta res2
 res = [{name:"sonu",roll:34,file:"asj.jpg", img_id:'1'},{name:"sonu",roll:34,file:"asj1.jpg", img_id:'2'}, {name:"sonu",roll:34,file:"asj2.jpg", img_id:'3'},{name:"dip",roll:67,file:"fgd3.jpg", img_id:'4'}, {name:"dip",roll:67,file:"fgd4.jpg", img_id:'5'},{name:"dip",roll:67,file:"fgd5.jpg", img_id:'6'}]

res convertir a como res2

 res2 = [{name:"sonu",roll:34, image: [{file:"asj.jpg",img_id:'1'},{file:"asj1.jpg", img_id:'2'},{file:"asj2.jpg", img_id:'3'}]}, {name:"dip",roll:67, image: [{file:"fgd3.jpg", img_id:'4'},{file:"fgd4.jpg", img_id:'5'},{file:"fgd5.jpg", img_id:'6'}]}]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

prueba esto

 var groupBy = function (xs, key) { return xs.reduce(function (rv, x) { (rv[x[key]] = rv[x[key]] || []).push(x); return rv; }, {}); }; var res0= groupBy(res, 'name'); var res2 = []; Object.keys(res0).forEach((item) => { var newObj = { name: item, roll: res0[item][0].roll, image: [] }; res0[item].forEach((obj) => { newObj.image.push({ file: obj.file, img_id: obj.img_id }); }); res2.push(newObj); });
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!