JSFiddle - React, Tailwind, and code Playground

by anpel13

HTML

<body>
    <button id="start">Start!</button>
    <button id="end">End!</button>
</body>

JavaScript

var myStart = document.querySelector('#start'),
        myEnd = document.querySelector('#end'),
        myRepeat;

function start() {
    console.log('Hello!')
    myRepeat = setTimeout(start, 1000)
}

function stop() {

    clearTimeout(myRepeat);
}

myStart.onclick = start;
myEnd.onclick = stop;