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

234
Views
atravesar (iterar) cada elemento de la matriz en un tiempo específico?

Tengo una matriz que tiene 200 elementos como -100 a 100. Quiero recorrer o iterar toda esta matriz en un tiempo específico. por ejemplo, quiero recorrer o iterar esta matriz en 5 segundos o también en 1 minuto. Depende del usuario que, en cuánto tiempo se defina para recorrer toda esta matriz. ¿Cómo puedo hacerlo?

 const array = [-100,-99,-98....0....98,99,100]; function traverseArr(){ .... }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Podría tomar una función para el intervalo y calcular la duración de cada elemento.

 function traverseArray(array, time, fn) { let i = 0; const handle = setInterval(() => { if (i < array.length) fn(array[i++]); else clearInterval(handle); }, time / array.length); } traverseArray([5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5], 10000, v => console.log(new Date().toISOString(), v));
 .as-console-wrapper { max-height: 100% !important; top: 0; }

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!