JSFiddle - React, Tailwind, and code Playground

HTML

<button id="start" >start</button>
<button id="stop">stop</button>

JavaScript

function start()
{
    console.log(start);
    var rndnr = (Math.round(Math.floor(Math.random()*5)+1))*1000;
    setTimeout(function timeout()
               {
                   document.bgColor="ffff00";
                   start = new Date();
               },rndnr);
}
function stop()
{
    var onclick = new Date();
    var time = onclick-start;
    var total;
    var avg;
    var count =1;
    document.getElementById("try 1").innerHTML = time;
    total = total + time;
    avg = total / count;
    count = count + 1;
    document.getElementById("avg1").innerHTML = avg;
 }

document.getElementById('start').onclick=function(){start();};
document.getElementById('stop').onclick=function(){stop();};