JavaScript Experiment

Imagine you are working in an ad agency.  One day you wake up, and an idea hits you. What if we conducted an experiment in which we measured the speed with which people typed the letter that’s displayed on the screen?  Would the order in which we showed the letters affect the speed with which people type the letters in?   You hypothesize that if participants recognize a pattern in the sequence, the latency with which they type in each letter will be lower (that is, they will type the letters faster).

To test your hypothesis, you create an experiment.  You show respondents a set of 20 six-letter sequences, one letter at a time, and ask them to type in the letter on the screen. You time how long each action takes. Some sequences you show are random non-word 6-letter combinations. Other sequences are drawn from a list of common six-letter words, such as:

  • worthy
  • values
  • unmask
  • rabies
  • medium
  • insure
  • health
  • better
  • arrive


Write a JavaScript program that:

On the first screen:

  • Displays instructions: “Today, we will be measuring your typing speed. On the next screen, you will see several sets of 6 letters, shown one at a time. Some of the sequences are real words (for example: w,o,r,t,h,y), others are random combinations (for example, m, m, i, d, u,e).  Using your keyboard, type in the letters you see on the screen as quickly and accurately as you can.  
  • Allows the user to select the number of sequences to try, from 1 to 20
  • Has a “Start” button that launches the experiment

On the experimental screen:

  • Shows the first letter in the sequence, waits for user input
  • Accepts user input
  • When the input is detected, the program records whether the input is correct (whether the button pressed is the same as the letter displayed), the latency (the amount of time between when the letter is displayed and the button is pressed), then proceeds to show the next letter in the sequence.
  • At the end of each sequence, displays "Next Sequence Starting Now" for 2 seconds.

At the end of the experiment, displays a table of results that, for each sequence, contains:

  • Characters shown
  • Number of errors
  • Mean latency
  • Whether the sequence was a real word


This problem requires that you write JavaScript code that evaluates the latency with which a user reacts to a stimulus on their computer. You can publish your solution online and send us a URL, or bring your laptop to the interview and show us the program in action. Many survey platforms allow custom questions written in JavaScript; this assignment will help us and you to understand whether this is something you can do. Please record the amount of time you spend working on the problem.