<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Robiul Cc</title>
    <description>The latest articles on DEV Community by Robiul Cc (@robiul_cc_5fdd440f1c88c45).</description>
    <link>https://dev.to/robiul_cc_5fdd440f1c88c45</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4209867%2F8c44442e-9f32-4672-bf85-19c0149af2c4.png</url>
      <title>DEV Community: Robiul Cc</title>
      <link>https://dev.to/robiul_cc_5fdd440f1c88c45</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/robiul_cc_5fdd440f1c88c45"/>
    <language>en</language>
    <item>
      <title>Five rounds, three answers: designing a reaction-game scorecard in JavaScript</title>
      <dc:creator>Robiul Cc</dc:creator>
      <pubDate>Wed, 25 Nov 2026 05:53:09 +0000</pubDate>
      <link>https://dev.to/robiul_cc_5fdd440f1c88c45/five-rounds-three-answers-designing-a-reaction-game-scorecard-in-javascript-187p</link>
      <guid>https://dev.to/robiul_cc_5fdd440f1c88c45/five-rounds-three-answers-designing-a-reaction-game-scorecard-in-javascript-187p</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpfr7xijdmvj2lnw10fq0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpfr7xijdmvj2lnw10fq0.jpg" alt=" " width="800" height="366"&gt;&lt;/a&gt;Here are five rounds from an imaginary reaction game, in the order somebody played them: &lt;strong&gt;241, 238, 246, 240, 515 milliseconds&lt;/strong&gt;. You have room for one large number on the result screen. What goes there?&lt;/p&gt;

&lt;p&gt;If you picked 238, I can picture the screen already. Big type, a little trophy, a button to challenge a friend. If you picked 296, you probably added the numbers and divided by five. If you picked 241, you sorted them and took the middle one. Each answer is defensible. Each tells a different story about the same thirty seconds at a keyboard.&lt;/p&gt;

&lt;p&gt;I run &lt;a href="https://voltreflex.com/" rel="noopener noreferrer"&gt;VoltReflex&lt;/a&gt;, where you can play a visual reaction test in sessions of five, ten, or twenty rounds and see your round history. The interesting design problem for this article starts after the last input arrives. Given a handful of observations, what can you put on a screen that a player can repeat to someone else without accidentally changing its meaning?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6sh9e9eksan9lr99v39s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6sh9e9eksan9lr99v39s.png" alt="Five example rounds at 241, 238, 246, 240 and 515 milliseconds. The fastest is 238 and the average is 296." width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/6sh9e9eksan9lr99v39s.png" rel="noopener noreferrer"&gt;Open the full-size scorecard chart&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The numbers below are invented so you can check every calculation. The code is a standalone exercise you can paste into a JavaScript console.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decide what the big number promises
&lt;/h2&gt;

&lt;p&gt;Imagine two people looking at the result over lunch. One asks, “How fast did you get?” The other asks, “What were you getting most of the time?” A perfectly natural answer to the first question is 238. A perfectly natural answer to the second is “somewhere around 240.” Nobody looking at the individual rounds would say they kept getting 296. Yet 296 is exactly their average.&lt;/p&gt;

&lt;p&gt;I would put &lt;strong&gt;Fastest round · 238 ms&lt;/strong&gt; on a challenge card meant to celebrate one good attempt. On a screen meant for someone reviewing a practice session, I would lead with &lt;strong&gt;Median of 5 rounds · 241 ms&lt;/strong&gt; and keep all five results within reach. This is one of those decisions I would make while drawing the interface on paper. Changing the font size after the calculation is finished is a surprisingly effective way to change the product.&lt;/p&gt;

&lt;p&gt;The word &lt;em&gt;round&lt;/em&gt; does real work here. Put “You reacted in 238 ms” next to a share button and it sounds like a statement about the person. Put “Fastest of five rounds: 238 ms” in the same space and a friend knows exactly what happened. That small piece of copy can survive a screenshot. A tooltip explaining the denominator probably won't.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give the fifth round somewhere to go
&lt;/h2&gt;

&lt;p&gt;Four of our values fit inside an eight millisecond window. The fifth takes more than twice as long as any of them. It is tempting to add an outlier rule right away. Before doing that, try writing the sentence the interface would show if the player asked where round five went. “We removed your slowest response because it made the graph look strange” sounds pretty bad out loud.&lt;/p&gt;

&lt;p&gt;We know only that the game recorded 515. Perhaps the player looked away. Perhaps they watched the cue the whole time. You cannot recover that distinction from the duration. You can, however, know that the page became hidden during a different trial if your app recorded that event. Those two situations deserve different entries in your model. One has a measured response. The other has an observed reason to interrupt a trial.&lt;/p&gt;

&lt;p&gt;Here is what the fifth response does to the arithmetic. The first four add up to 965, giving a mean of 241.25. Add 515 and the total becomes 1,480. Divide by five and you get 296. Nobody needs to have scored near 296 for that calculation to be right. A mean answers a question about the whole total, and every extra millisecond in the total gets a vote.&lt;/p&gt;

&lt;p&gt;There is a friendly way to explain this without fitting a statistics lesson onto a phone. Show the five rounds in order. Highlight the fastest with a small label and leave the fifth visible at its actual size. A player can point at the long bar and understand the difference between their fastest round and their average before opening any help text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep attempts and completed rounds separate
&lt;/h2&gt;

&lt;p&gt;Suppose the first tap came early, the next two rounds completed, and the player switched tabs during the following wait. When the interface says “Round 3 of 5,” is that a bug? It depends on what you promised. If the button said “Play five scored rounds,” two are complete. If it said “Make five attempts,” four attempts have already happened. An array called &lt;code&gt;scores&lt;/code&gt; will struggle to explain both stories.&lt;/p&gt;

&lt;p&gt;For this exercise I would record one entry per attempt and give each entry an explicit outcome. A scored attempt carries a duration. An early attempt carries the reason it ended. An interrupted attempt can carry a reason such as a hidden page. I would derive the count beside the progress bar by counting scored entries. Two early taps would still appear in the history, but neither would turn into a zero in the average.&lt;/p&gt;

&lt;p&gt;A zero is particularly nasty here because it looks fantastic. An empty field that slips through a numeric conversion can turn an unfinished session into a personal record. Make that failure obvious to the developer. If an entry calls itself scored and its duration is missing, the example below throws an error. A production interface could offer to restart or recover the session, while keeping the bad record out of the results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;summarize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;times&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;outcome&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"early"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;outcome&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"interrupted"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;outcome&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;"scored"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
        &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isFinite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TypeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Unexpected attempt or invalid duration"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sorted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;middle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;median&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;middle&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;middle&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;middle&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;fastest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;median&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;rounds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;241&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;238&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;246&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;240&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;515&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;outcome&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"scored"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ms&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;summarize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rounds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// { count: 5, fastest: 238, mean: 296, median: 241 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I like returning a distinct empty result because it forces a decision in the view. Before the first completed round, the score panel can say “Your first result will appear here.” If a player leaves after three completed rounds, the panel can say “Three rounds completed” and show those three. A dash with no explanation makes those two states look remarkably alike.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preserve the order somebody actually played
&lt;/h2&gt;

&lt;p&gt;The sorted copy in that function is deliberate. The median needs the values in increasing order. The history needs them in the order somebody played. Sort your only copy in place and a chart can quietly turn into a fictional account of a player getting slower with every click. All the arithmetic checks still pass. You need a check for the story told by the chart.&lt;/p&gt;

&lt;p&gt;Take the exact same five numbers and put 515 first. The fastest, mean, and median stay the same. The experience changes quite a bit. Seeing one long first round followed by four closely grouped responses might prompt a question about whether the opening instructions were clear. Seeing a long last round suggests a different question. Neither observation establishes a cause, but knowing the order gives you a sensible place to start looking.&lt;/p&gt;

&lt;p&gt;For a round history I would give the horizontal or vertical axis the simplest labels possible: round one, round two, round three. In a ranking view I would be equally explicit about sorting and keep the original round number beside each value. A “fastest first” switch is fine as long as switching it off brings the player back to the sequence they remember.&lt;/p&gt;

&lt;p&gt;A small screen adds one more wrinkle. If you display only the latest three values, the score in large type might refer to a round that has already scrolled away. A tiny “Round 2” beside a best time lets someone find it again. It also settles a surprisingly basic support question: “Where did that number come from?” You can answer it without making anyone redo the session.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare sessions without letting the rules drift
&lt;/h2&gt;

&lt;p&gt;Here is a little trick you can try with pencil and paper. Write down five times. Circle the smallest. Add fifteen more times to the bottom of the page and circle the smallest value on the entire sheet. Your second circle will land on the same number or a smaller one. There is no possible set of fifteen extra observations that makes the minimum of that growing list larger.&lt;/p&gt;

&lt;p&gt;That simple fact changes how a leaderboard reads. If one person shares their best of twenty and another shares their best of five, the player with twenty rounds had more opportunities to produce a quick one. They might still lose. The point is that the rules gave them a different number of chances. Putting the round count on the card makes the comparison much easier to discuss.&lt;/p&gt;

&lt;p&gt;A fairer challenge between friends could be as ordinary as agreeing to five completed rounds each, using the same game mode, then sharing the entire session. If they are curious about differences between a laptop keyboard and a phone screen, they can label the two setups. If they are just having fun, no one needs a form asking for the serial number of their mouse. Ask for the information the comparison actually uses.&lt;/p&gt;

&lt;p&gt;I would also decide what happens when a player restarts after a slow round. A local game can happily offer unlimited restarts. Calling the best surviving session somebody's “usual speed” is a bigger claim. A result screen can avoid that trap with a date or session label and a plain description of what was saved. The player gets to celebrate, and their friend gets to decide what that celebration means.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design the shared result outside the app
&lt;/h2&gt;

&lt;p&gt;Try a copywriting test before you build the export button. Paste the proposed share text into a blank message, close the game, and read the message as someone who has never seen it. “I got 238!” leaves at least three questions open. Is lower better? Was this one click or a whole game? What was the task? “Visual reaction game, fastest of 5 completed rounds: 238 ms” travels much better.&lt;/p&gt;

&lt;p&gt;The same exercise works for an image. A nice looking card might lose its heading when a messaging app crops the thumbnail. Keep the unit and the metric label close to the number. Include the round count as text someone can read on a small screen. For a text-only alternative, generate a sentence from the same summary object. That way editing the formatting in one component cannot quietly turn a median into an average elsewhere.&lt;/p&gt;

&lt;p&gt;Think about a tie while you have the card open. Suppose the fastest two rounds are both shown as 238 after rounding. Internally, one was 237.6 and one was 238.4. A trophy beside only one of two identical labels looks arbitrary. You could show both as joint fastest at display precision, or show another decimal in the detailed history. Whichever rule you pick, make the highlight and the displayed explanation agree.&lt;/p&gt;

&lt;p&gt;I would retain the original values for calculations and apply display rounding at the last step. For example, three durations of 240.49, 240.49, and 241.49 have a mean of about 240.82. Rounded once at the end, the mean displays as 241. Round every input first and you get 240, 240, and 241, whose mean displays as 240. It is only a millisecond, but it is also the kind of discrepancy somebody will patiently reproduce for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the results screen with awkward little sessions
&lt;/h2&gt;

&lt;p&gt;Start with one completed round. All three summary values should agree. Next, enter two completed rounds of 200 and 300. Their median should be 250, which checks the even-length branch without requiring anyone to mentally sort a long list. Then feed in rounds of 90, 105, and 1000. If you accidentally used JavaScript's default string ordering, this is a much better witness than a list of three-digit numbers.&lt;/p&gt;

&lt;p&gt;Now try an early attempt between two good rounds. The history should have three entries, the summary should have two scored rounds, and the progress indicator should be ready for the third. If the same two rounds appear with an interrupted attempt instead, the arithmetic should stay the same while the history message changes. These are two separate assertions. A function can be perfectly right about addition while the interface blames the player for an interruption.&lt;/p&gt;

&lt;p&gt;My favorite check is to save a copy of the original attempt order, open the summary twice, and compare the history with the copy. Then open the share sheet and do it again. Read operations are easy to overlook in tests because their names sound harmless. A helper buried inside a share card can still reorder an array that the rest of the page uses.&lt;/p&gt;

&lt;p&gt;Finally, hand the result to somebody with one narrow question: “Which round does the large number describe?” If they answer “all five” when the card shows a fastest round, you have learned more than a passing snapshot test could tell you. Change the label, give the card back, and ask again. For our original five rounds, I would be happy to ship a screen where a friend could glance at it and say, “You got 238 on round two. What happened on round five?” That is a conversation the actual data can support.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gamedev</category>
      <category>testing</category>
      <category>ux</category>
    </item>
    <item>
      <title>Why a rhythm game can report 0 ms when every tap missed</title>
      <dc:creator>Robiul Cc</dc:creator>
      <pubDate>Tue, 24 Nov 2026 03:31:23 +0000</pubDate>
      <link>https://dev.to/robiul_cc_5fdd440f1c88c45/why-a-rhythm-game-can-report-0-ms-when-every-tap-missed-49k1</link>
      <guid>https://dev.to/robiul_cc_5fdd440f1c88c45/why-a-rhythm-game-can-report-0-ms-when-every-tap-missed-49k1</guid>
      <description>&lt;p&gt;Imagine four taps landing 60 ms early, 60 ms late, 40 ms early and 40 ms late. If a results screen averages those offsets and displays “0 ms,” the arithmetic is correct. Every tap still missed its target.&lt;/p&gt;

&lt;p&gt;When designing a timing game, keep the sign until you know which question the score needs to answer. Subtract the target timestamp from the input timestamp. A negative offset means the player pressed early. Then calculate two numbers from the same observations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;offsetsMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;mean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;biasMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;offsetsMs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                 &lt;span class="c1"&gt;// 0&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;averageMissMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;offsetsMs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 50&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example assumes at least one recorded tap. For an empty round, show “No taps recorded.” Substituting zero would give a player who missed every beat a perfect-looking score.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two runs worth testing
&lt;/h2&gt;

&lt;p&gt;I run VoltReflex. In our &lt;a href="https://voltreflex.com/rhythm-accuracy-test/" rel="noopener noreferrer"&gt;rhythm accuracy test&lt;/a&gt;, choose 100 BPM, listen to the four-beat count-in, then tap along for 16 beats. On a second run, deliberately tap a little late each time. Look at the early/late figure alongside the average error. A steady player can still be consistently late.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://voltreflex.com/anticipation-timing-test/" rel="noopener noreferrer"&gt;anticipation timing test&lt;/a&gt; gives the same scoring question a visual twist. Press when the moving dot reaches the line. The target moves at three speeds, so watch whether your early or late tendency changes when the dot speeds up.&lt;/p&gt;

&lt;p&gt;One useful test case for a results screen is to enter four offsets of +50 ms, then the four alternating offsets above. Both runs should show an average miss of 50 ms. Only the first should tell the player they were consistently late.&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>VoltReflex: a free reaction time test, and what browser scores really measure</title>
      <dc:creator>Robiul Cc</dc:creator>
      <pubDate>Thu, 29 Oct 2026 03:14:54 +0000</pubDate>
      <link>https://dev.to/robiul_cc_5fdd440f1c88c45/voltreflex-a-free-reaction-time-test-and-what-browser-scores-really-measure-971</link>
      <guid>https://dev.to/robiul_cc_5fdd440f1c88c45/voltreflex-a-free-reaction-time-test-and-what-browser-scores-really-measure-971</guid>
      <description>&lt;p&gt;I built &lt;a href="https://voltreflex.com/" rel="noopener noreferrer"&gt;VoltReflex&lt;/a&gt;, a free visual reaction time test that runs in your browser. The interaction is simple: wait for the screen to turn green, then click or tap. You can choose a session of 5, 10, or 20 rounds, review your best and average times, and share your results.&lt;/p&gt;

&lt;p&gt;There is no account to create and no app to download. But a small browser tool like this raises an interesting question: what does the number on the screen actually represent?&lt;/p&gt;

&lt;h2&gt;
  
  
  The score includes more than your reflexes
&lt;/h2&gt;

&lt;p&gt;A visual reaction test measures the time between a visual cue and an input event. That sounds straightforward, but the path from a browser update to a recorded click includes several steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The browser schedules and renders the visual change.&lt;/li&gt;
&lt;li&gt;The display presents that change.&lt;/li&gt;
&lt;li&gt;You notice the cue and respond.&lt;/li&gt;
&lt;li&gt;Your mouse, keyboard, or touchscreen delivers the input.&lt;/li&gt;
&lt;li&gt;The browser processes the event.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your reaction is part of that chain. Display refresh rate, input hardware, browser workload, and device performance can also influence the result. A browser score should therefore be treated as a practical estimate under your current conditions, rather than a laboratory measurement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare sessions under similar conditions
&lt;/h2&gt;

&lt;p&gt;If you want to compare your own attempts, keeping the setup consistent is useful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the same device and input method.&lt;/li&gt;
&lt;li&gt;Keep the browser and display settings consistent.&lt;/li&gt;
&lt;li&gt;Avoid switching between a touchscreen and a mouse when comparing scores.&lt;/li&gt;
&lt;li&gt;Take several rounds instead of drawing conclusions from one unusually fast result.&lt;/li&gt;
&lt;li&gt;Pause if you feel tired or find yourself guessing when the cue will appear.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A lower number on a different device does not automatically mean your underlying reaction speed improved. The measurement environment may have changed too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why show both best and average times?
&lt;/h2&gt;

&lt;p&gt;The best result tells you about your fastest recorded attempt in a session. The average gives a broader picture of the rounds you completed. They answer different questions, so VoltReflex shows both.&lt;/p&gt;

&lt;p&gt;For example, one very quick attempt alongside several slower ones can produce a strong best time without a similarly strong average. Looking at both makes the session easier to interpret than looking at a single headline number.&lt;/p&gt;

&lt;p&gt;The 5-, 10-, and 20-round options let you choose between a short check and a longer session. They are not a medical assessment or a way to diagnose a condition.&lt;/p&gt;

&lt;h2&gt;
  
  
  A small tool with room for feedback
&lt;/h2&gt;

&lt;p&gt;VoltReflex works on desktop and mobile, and the shareable result makes it easy to compare attempts with friends. My aim is to keep the test easy to understand: wait, react, review, and try again if you want to.&lt;/p&gt;

&lt;p&gt;You can try the &lt;a href="https://voltreflex.com/" rel="noopener noreferrer"&gt;online reaction time test on VoltReflex&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I would appreciate feedback from other developers, especially on mobile usability and how clearly the results explain device-related limitations. If you were presenting browser timing results to users, what context would you include alongside the score?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I am the creator of VoltReflex. This post was drafted with AI assistance and describes the tool's current user-facing features; it is not a technical audit of its timing implementation.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>showdev</category>
    </item>
    <item>
      <title>How Browser-Based Reaction Time Tests Work</title>
      <dc:creator>Robiul Cc</dc:creator>
      <pubDate>Tue, 27 Oct 2026 03:55:54 +0000</pubDate>
      <link>https://dev.to/robiul_cc_5fdd440f1c88c45/how-browser-based-reaction-time-tests-work-cm</link>
      <guid>https://dev.to/robiul_cc_5fdd440f1c88c45/how-browser-based-reaction-time-tests-work-cm</guid>
      <description>&lt;p&gt;A reaction time test looks simple: wait for a color change, then click. Behind the result are a timer, browser rendering, input events, and measurement limits.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://voltreflex.com/" rel="noopener noreferrer"&gt;VoltReflex&lt;/a&gt; is our free browser-based visual reaction test. This article explains the general ideas behind a test like it; the example below is illustrative, not VoltReflex’s production code.&lt;/p&gt;

&lt;h2&gt;
  
  
  The basic sequence
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Start a trial and wait for a random delay.&lt;/li&gt;
&lt;li&gt;Show a visual signal and record a timestamp.&lt;/li&gt;
&lt;li&gt;When the player responds, record a second timestamp.&lt;/li&gt;
&lt;li&gt;Subtract the first timestamp from the second and repeat across multiple trials.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Randomizing the delay makes it harder to predict the signal. A response before the signal should be treated as a false start, rather than a fast result.&lt;/p&gt;

&lt;h2&gt;
  
  
  A small JavaScript example
&lt;/h2&gt;

&lt;p&gt;This example assumes a button with id "test" and an element with id "result". Click once to start, then again after it turns green.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#result&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;startedAt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;waiting&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;background&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;orange&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Wait for green...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;timer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;background&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;green&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;startedAt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ready&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;3500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;waiting&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;background&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Too early. Click to try again.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;startedAt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;idle&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;background&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Response: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;elapsed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; ms. Click to retry.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a teaching example, not a complete production implementation. A real test should handle keyboard and touch input accessibly, prevent accidental repeated events, reset state cleanly and report multiple rounds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timer precision is not end-to-end accuracy
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;performance.now()&lt;/code&gt; is a monotonic clock suitable for measuring elapsed time. But setting a CSS color does not mean the new pixels are visible at that exact instant. The browser still has to render a frame, the display must refresh, and the input event has its own path through hardware and the operating system. Main-thread work can also delay callbacks or event handling.&lt;/p&gt;

&lt;p&gt;At 60 Hz, one refresh interval is about 16.7 ms; at 144 Hz it is about 6.9 ms. These are frame intervals, not a complete measurement of display latency. High-resolution timestamps cannot remove delays elsewhere in the chain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make results more useful
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Record several trials and show the average alongside individual scores.&lt;/li&gt;
&lt;li&gt;Explain false starts and allow retries.&lt;/li&gt;
&lt;li&gt;Compare sessions on the same device, browser and input method.&lt;/li&gt;
&lt;li&gt;Avoid presenting browser results as clinical measurements or precise comparisons across different hardware.&lt;/li&gt;
&lt;li&gt;Keep the interface usable with a keyboard and provide feedback that does not rely on color alone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a ready-to-use example, try &lt;a href="https://voltreflex.com/" rel="noopener noreferrer"&gt;VoltReflex&lt;/a&gt; and compare its multi-round results on the same setup. A single number is interesting; a consistent method makes it more meaningful.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This article was prepared with AI assistance.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
