t = TrafficLight(); b = Button(); es = []; b.onclick(function () { t.red(); es.push(now()); if (es.length == 6) report(); else start(); }); start = function () {setTimeout(go, Math.random() * 3000)} go = function () {t.green(); es.push(-now())}; report = function () { print("Average: " + 0 + "ms"); print("Longest: " + 0 + "ms"); }; start(); "Ready...";
Output