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

75
Views
cómo hacer coincidir los datos de 2 matrices y crear una nueva matriz

tengo la siguiente matriz

 response=[ { "mId": "4a993417-3dae-4a85-bb2e-c535d7fda6d7", "title": "test2", "score": "4", "id": "91ce873f-6e58-4c30-86d4-4eb7f200640e" } ] [ { "mId": "7896548-3dae-4a85-bb2e-c855d7fda6d7", "title": "discussion", "score": "18", "id": "91ce873f-6e58-4c30-86d4-4eb7f200640e" } ] [ { "mId": "20d78952-3dae-4a85-bb2e-c535d7fda6d7", "title": "test", "score": "1", "id": "7777777f-6e58-4c30-86d4-4eb7f200640e" } ]

luego tengo otra matriz que se ve de la siguiente manera

 mixture=[{"id":"4a993417-3dae-4a85-bb2e-c535d7fda6d7","name":"flour","description":"10g sold"}] [{"id":"20d78952-3dae-4a85-bb2e-c535d7fda6d7","name":"teabag","description":"stock arriving"}]

¿Cómo verifico el mId de la matriz de respuesta en la matriz correspondiente de la mezcla para recuperar el nombre para que mi nueva matriz se vea de la siguiente manera?

 newArray=[{ "name":"flour" "mId": "4a993417-3dae-4a85-bb2e-c535d7fda6d7", "title": "test2", "score": "4", "id": "91ce873f-6e58-4c30-86d4-4eb7f200640e" }] [{ "name":"flour" "mId": "4a993417-3dae-4a85-bb2e-c535d7fda6d7", "title": "discussion", "score": "18", "id": "91ce873f-6e58-4c30-86d4-4eb7f200640e" }] [{ "name":"testbag" "mId": "7896548-3dae-4a85-bb2e-c855d7fda6d7", "title": "test", "score": "1", "id": "7777777f-6e58-4c30-86d4-4eb7f200640e" }]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Siempre que escriba su respuesta y matrices de mezcla correctamente, puede lograrlo usando una combinación de Array.prototype.map() y Array.prototype.find()

 const newArray = response.map(item => { const mix = mixture.find(mix => mix.id === item.mId); if (mix) { item.name = mix.name; } return item; })
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!