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

155
Vistas
The purpose of the button is to pop up a red circle for 3 seconds using some sort of loop to monitor the time

I have a small amount of experience with setInterval() so I'm not quite sure how to use it . In the past , I've even tried setTimeout() in this code ,but then realized that setInterval() is better. I'm trying to write it with as little code as I can. Anyways, I only need this part of the code helped out with, and then I'll be able to put in the big one that I' working on . To summarize the ultimate purpose, this code is supposed to show where the hidden treasure is on the map, that circle is gonna pop up where the treasure is located and the user has to click around the field and try to find it. The main code is finished but I just cant figure out how to make this hint. While setInterval() is below 3000(3 seconds) the circle shows, when the circle disappears , the timer keeps going so that the user couldn't use the hint more than once.

let elem = document.getElementById("hint");

elem.addEventListener('click', myFunction(){
setInterval(myFunction, 3050);


    function myFunction(time){
        while (time<3000){
        let c = document.getElementById("myCanvas");
        let ctx = c.sdgetContext("2d");
        ctx.beginPath();
        ctx.arc(110,80, 70,0, 2 * Math.PI);
        ctx.fillStyle ="red";
        ctx.globalAlpha = "0.6";
        ctx.fill();
         }
    }
});
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