JSFiddle - React, Tailwind, and code Playground

HTML

<input type="number" id="input" value="0"/>
<input type="button" onclick="stop()" value="stop"/>
<input type="button" onclick="start()" value="start"/>

JavaScript

(function(){
var i = 0;
    function stop(){
    clearTimeout(i);
    }
    
    function start(){
    i = setTimeout( timed, 1000 );
    }
    
    function timed(){
    document.getElementById("input").value++;
    start();
    }
    
window.stop = stop;
window.start = start;
})()