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

202
Vistas
How do i make a countdown loop

I need to make a clicker game and in it i need an upgrade that adds clicks per seconds. How do i make a loop that every second it adds to the points variable? this is in JavaScript by the way. I have tried googling an answer and that did not help, an anyone help me with this?

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

0

Do you want the clicks per seconds feature? I am not sure what exactly you looking for.
as Aviv Ben Shahar already answered to use setInterval.

here is the code you might looking for.

const clicksdom = document.getElementById("clicks");
const hclicksdom = document.getElementById("hclicks");
var clicks=0;
var hclicks=0;
document.addEventListener("click",()=>{
  clicks+=1;
});
const intervalId = setInterval(()=>{
  if(clicks>=hclicks){
    hclicks = clicks;
  }
  hclicksdom.innerText = hclicks;
  clicksdom.innerText = clicks;
  clicks = 0;
}, 1000) 
<div>
  <p>Clicks Per Seconds</p>
  <p>highest cps <span id="hclicks">--</span></p>
  <p>current cps <span id="clicks">--</span></p>
</div>

// To kill the interval loop
clearInterval(intervalId)
about 4 years ago · Juan Pablo Isaza Denunciar

0

const intervalId = setInterval(()=>{
   ... DO STUFF HERE
  
}, 1000) // will happened every 1000 milliseconds 


// To kill the interval loop
clearInterval(intervalId)

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