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

218
Views
Eliminar objeto de una matriz si el valor clave coincide

hola tengo este objeto

 obj = [ {id: 145, value: '$ 1.024.100'} {id: 146, value: '$ 679.200'} {id: 147, value: '$ 679.200'} ]

De una casilla de verificación, obtengo un valor y una identificación, estoy intentando que si ese valor y la identificación coinciden, elimine la matriz que coincide

Entonces busco que si el valor e id que envio es por ejemplo $ 679.200 y 146 el resultado obj es este

 obj = [ {id: 145, value: '$ 1.024.100'} {id: 147, value: '$ 679.200'} ]

Intenté esto pero no funciona

 var index: number = obj.indexOf(ob.source.value, id); obj.splice(index, 1);

Lo elimina pero no el valor y la identificación que coinciden

cualquier ayuda se lo agradecere

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

0

Usando Array#findIndex :

 const removeElemWithIdAndValue = (arr = [], targetId, targetValue) => { const index = arr.findIndex(({ id, value }) => id === targetId && value === targetValue); if(index >= 0) arr.splice(index, 1); } const arr = [ {id: 145, value: '$ 1.024.100'}, {id: 146, value: '$ 679.200'}, {id: 147, value: '$ 679.200'} ]; removeElemWithIdAndValue(arr, 1461, '$ 679.200'); console.log(arr);

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!