From 573e706379621078b0fc6242689038f53d3ab228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=A0=E5=B0=98?= <130227171+wuchenchina@users.noreply.github.com> Date: Sat, 11 Nov 2023 18:33:57 +0800 Subject: [PATCH] Update script.js --- script.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 6bada27..17c19ad 100644 --- a/script.js +++ b/script.js @@ -22,7 +22,8 @@ function showRandomShape() { function shapeClicked() { const endTime = new Date(); - const reactionTime = (endTime - startTime) / 1000; + // 将反应时间改为毫秒 + const reactionTime = endTime - startTime; reactionTimes.push(reactionTime); this.remove(); @@ -39,8 +40,9 @@ function getRandomColor() { } function endGame() { + // 计算平均反应时间,精确到毫秒 const average = reactionTimes.reduce((a, b) => a + b, 0) / reactionTimes.length; - alert(`测试完成!\n平均反应时间:${average.toFixed(2)} 秒`); + alert(`测试完成!\n平均反应时间:${average.toFixed(2)} ms`); document.getElementById('start-button').classList.remove('hidden'); reactionTimes = []; }