Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
Recursive function not incremeanting its own parameter

var documentURLs = ["maca.pdf", "maca2.pdf"]
function printDocuments(index){
   if(index > documentURLs.length){
        return;
   }
   else {
     printJS({
       printable: documentURLs[index],
       type: 'pdf',
       onPrintDialogClose: function () {
         console.log(index);
          printDocuments(index++)
       }
     })
   }
}
<button type="button" onclick="printDocuments(0)">Print</button>

This is not incrementing the index, always print first document and it is not stopping

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It behaves exactly as it should. If you want to call printDocuments with the next index, you should use printDocument(++index) or justprintDocument(index+1), because it's the least confusing one. i++ returns current value of i and then adds 1. ++i first adds 1 and returns that increased value (so i+1).

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda