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

150
Views
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
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!