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

168
Views
Cómo obtener el índice de múltiples ID en respuesta

El siguiente código obtiene un índice de ID específico como respuesta. Funciona bien cuando ID es el único. Pero ahora tengo 3 identificaciones. Entonces, ¿qué hacer para obtener múltiples índices de múltiples ID?

 function getIndex(CategoryID) { return response.responseContents.findIndex( (obj) => obj.CategoryID === CategoryID, ); } const index = getIndex(CategoryToGetName);
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Puede hacer un bucle for simple en el que complete una matriz con los índices coincidentes.

 let idxs = []; for (let i in response.responseContents) { if (response.responseContents[i] == CategoryID) idxs.push(parseInt(i)); } return idxs;
about 4 years ago · Juan Pablo Isaza Report

0

Podrías hacer algo como:

 function getIndex(CategoryID) { return response.responseContents.map((obj, index) => { if (obj.CategoryID === CategoryID) { return index; } } } const index = getIndex(CategoryToGetName);
about 4 years ago · Juan Pablo Isaza Report

0

Por favor intente debajo del código

 findIndex(CategoryIDS){ return response.responseContents.filter((r,index)=> if(CategoryIDS.indexOf(r.CategoryID)>-1){ return index; } ) }
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!