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

138
Views
Cómo lidiar con esta estructura de datos en javascript

Estoy atascado en un problema y no tengo idea de en qué dirección debo ir. Hay una matriz de objetos y quiero verificar si anteriormente había un tipo exacto, si es así, copie las propiedades y agregue una nueva sin una propiedad de tipo, si no, empuje el objeto a la matriz.

Ejemplo 1:

Entrada esperada:

 const arr = [ {type: 1, amount: 100}, {type: 2, amount: 200}, {type: 3, amount: 300}, ] const obj = {type: 1, name: 'PLN'}

Rendimiento esperado:

 arr = [ {type: 1, amount: 100, name: 'PLN'}, {type: 2, amount: 200}, {type: 3, amount: 300}, ]

Ejemplo 2:

Entrada esperada:

 const arr = [ {type: 1, amount: 100}, {type: 2, amount: 200}, {type: 3, amount: 300}, ] const obj = {type: 4, amount: 400}

Rendimiento esperado:

 arr = [ {type: 1, amount: 100}, {type: 2, amount: 200}, {type: 3, amount: 300}, {type: 4, amount: 400}, ]

Si algo no está claro, por favor hágamelo saber :)

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!