Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchenchina authored Nov 11, 2023
1 parent 22ad63c commit 573e706
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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 = [];
}

0 comments on commit 573e706

Please sign in to comment.