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

181
Vistas
How to call the setinterval id saved in stopWatch() from another function?

If you set the variable interval globally, it works normally.

But I want to save the variable interval inside stopWatch() and then call the interval value with hiddenPopUp().

The code below doesn't seem to be able to return an interval...

function stopGame() {
  hiddenPopUp(stopWatch);
}

// let interval;
function stopWatch() {
  let interval = setInterval(() => {
    if (timeStart < 0) {
      clearInterval(interval);
      return;
    } else {
      time(timeStart);
    }
  }, 1000);
  return interval;
}

function hiddenPopUp(interval) {
  clearInterval(interval);
}
about 4 years ago · Juan Pablo Isaza
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