JSFiddle - React, Tailwind, and code Playground

HTML

<span id="box"></span>

CSS

span#box {
   border: 2px solid black;
    background: #666;
   color: white;
    font-size: 26px;
    padding: 5px;
}

JavaScript

function cooldown(element, start, stop, step, delay) {
    var current = start;
    element.innerHTML = current
    var timer = setInterval(function () {
        current -= step;
        if(current < stop) current=stop;
        element.innerHTML = current;
        if(current == stop) clearInterval(timer);
    }, delay*1000);
}

var box = document.getElementById("box");
cooldown(box, 30, 0, 15, 3);