JSFiddle - React, Tailwind, and code Playground

by Alexis López Espinoza

HTML

<label id = "tiempo">30:00</label>

JavaScript

var label = document.getElementById("tiempo"),
    minutos = 30,
    segundos = 0,
    intervalo = setInterval(function(){
        if (--segundos < 0){
            segundos = 59;
            minutos--;
        }
      
        if (!minutos && !segundos)
            clearInterval(intervalo);
  
        label.innerHTML = minutos + ":" + (segundos < 10 ? "0" + segundos : segundos);
    }, 1000);