JSFiddle - React, Tailwind, and code Playground

by Zubair Anwar

HTML

<div id="countdown">0</div>

CSS

#countdown{
    font-size: 5em ;
}

JavaScript

var count=0;

var counter=setInterval(timer, 50); //1000 will  run it every 1 second

function timer()
{
  count=count+1;
  if (count >= 24)
  {
     clearInterval(counter);
     //counter ended, do something here
      document.getElementById("countdown").innerHTML=24 ;
      
     return;
  }

  //Do code for showing the number of seconds here
     document.getElementById("countdown").innerHTML=count ; // watch for spelling

}