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

275
Views
devolver el índice del nuevo elemento barajado

Esto es lo que quiero:

Tengo la first matriz y tengo el index de la siguiente manera:

 const first = ['a','b','c']; const index = 1; // the index of b const shuffled = ['c','a','b']; // now the index of b is 2

En la first matriz, el index apunta al segundo elemento de la matriz, que es b , ¿verdad?

Ahora mezclé la first matriz y tenemos la matriz shuffled .

El índice de b es 2 en este momento. Quiero devolver este nuevo índice...

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

0

Usando Array#indexOf :

 const first = ['a','b','c']; const index = 1; const shuffled = ['c','a','b']; const target = first[index]; const newIndex = shuffled.indexOf(target); console.log(newIndex);

about 4 years ago · Juan Pablo Isaza Report

0

Puedes usar,

Sea valor = primero[índice]

let newValue =shuffled.indexof(valor)

about 4 years ago · Juan Pablo Isaza Report

0

puedes usar shuffled.indexOf(first[index])

first[index] devuelve el valor del first index en este caso 'b'

shuffled.indexOf('b') devolvería el índice de b en la matriz shuffled

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!