Implementing A Stopwatch — The Lame, AI-Generated Introduction

The writing is not AI-generated, but the code is

Evan SooHoo
2 min readJan 23, 2025

Let me give you the 30-second version:

Let’s just pretend that I woke up one morning, and I really wanted to make my own JavaScript stopwatch. I am definitely interested in this question for that reason, and not because the “stopwatch challenge” is currently a popular interview question for frontend positions.

The Challenge

  • The interview candidate is given about 45 minutes to complete the challenge
  • The interview candidate is given a blank page with which to program an es6 class from scratch. The class needs to have three functions — startTimer, stopTimer, and resetTimer. It should include a main that demonstrates basic functionality
  • In what remains of the 45 minutes, the candidate is to rig up these functions into one of three frameworks — Angular, React, or Vue

The Lame Solution

I only call this solution lame because it is not my solution. What I hope to do is use it as a starting point.

One thing to consider is precision. Without adjusting using current timestamp, you can get an inaccurate stopwatch.

Other than that, the only thing that really matters is that interview candidates follow the #1 cardinal rule of programming interviews: Have fun.

Note that the above:

  • Uses Date.now() instead of relying solely on setTimeout
  • Use a main to use the constructor and demonstrate all three functions

I tried running with Node.js via console. Looks fine.

Here is ChatGPT putting it in Vue.

Looks decent. Works fine.

Not much to say about the Vue.js version other than that it uses mustache syntax to display time, three buttons, and the disabled attribute.

Next Steps

I’ll let you know how the non AI-generated one works.

--

--

Evan SooHoo
Evan SooHoo

Written by Evan SooHoo

I never use paywalls (anymore) because I would get stuck behind them.

No responses yet