Timer is not working_Help please

Timer is not working_Help please
0

#1

I’m using a tutorial to create some basic code to make a timer. Using p5.js for this. The code doesn’t seem to be running. What can I do differently? Thanks!


#2

mebbe something like…

function setup()
{
	noCanvas(); 
	var timer = select('#timer'); 
        var timeLeft = 15;
        var counter = timeLeft;
  function timeIt()
  {	counter--;
	timer.html(counter);
    if( counter <= 0)
      { clearInterval(tick);  
        timer.html(counter + "<br>STOPPED"); 
      }
  }
  timer.html(counter + "<br>STARTING"); 	
	var tick = setInterval(timeIt, 1000) 
}

#3

Thanks. I figured it out. I wasn’t using the right p5.js library.