const records = []; ------------------------------------------------------ ①
$screen.addEventListener('click', function () {
if ($screen.classList.contains('waiting')) { // 대기 화면
(중략)
} else if ($screen.classList.contains('ready')) { // 준비 화면
} else if ($screen.classList.contains('now')) { // 측정 화면
endTime = new Date();
①
const current = endTime - startTime;
records.push(current);
const average = records.reduce((a, c) => a + c) / records.length; --- ②
$result.textContent = `현재 ${current}ms, 평균: ${average}ms`; ------ ③
④
startTime = null;
endTime = null;
$screen.classList.replace('now', 'waiting');
$screen.textContent = '클릭해서 테스트를 시작하세요';
}
});