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 puedo hacer que mi bucle de JavaScript funcione más lento?

Estoy probando un poco de codificación y me gustaría que las cadenas de 30 caracteres aparezcan en intervalos de 1 segundo una tras otra cuando se inicia el código. Probé setInterval & setTimeout y no pude hacerlo funcionar. Si alguien pudiera ayudarme sería muy apreciado.

 count = 0 while (count < 200) { console.log(create_random_string(30)) function create_random_string(string_length){ var random_string = ''; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz' for(var i, i = 0; i < characters.length; i++){ random_string += characters.charAt(Math.floor(Math.random() * characters.length)) } return "|BTC| " + random_string + " | " + " PRIVATNI KLJUČ NIJE ISPRAVAN" + " | " + " STANJE: 0.00" } count = count + 1 }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

setInterval(code, time);

esta función te permitirá esperar X milisegundos antes de ejecutar el código definido.

aquí, el código correcto, y arreglé un poco tu formato.

 let count = 0; while (count < 200) { setTimeout( function() { console.log(create_random_string(30)); } , 500); count++; } function create_random_string(string_length){ var random_string = ''; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz' for(var i, i = 0; i < characters.length; i++){ random_string += characters.charAt(Math.floor(Math.random() * characters.length)) } return "|BTC| " + random_string + " | " + " PRIVATNI KLJUČ NIJE ISPRAVAN" + " | " + " STANJE: 0.00" }

por cierto, probablemente querías reemplazar characters.length . longitud dentro de tu ciclo for por: cadena_longitud para usar el parámetro de la función (que en realidad nunca usaste)

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!