Lloyd Atkinson
This Year's Christmas Quiz

You can play it here. 🎄🎅

In 2021, I started a tradition of building a project around Christmas time. In 2021, I created a trivia quiz, and in 2022, I created a music quiz. This year, I created a trivia quiz again.

I previously wrote about how I created the 2022 quiz here. This year’s is effectively a branch of that project, with a few changes.

The main change is that I’ve added time-sensitive questions. The longer the player takes to answer the question, the fewer their points. I implemented this as it seemed that people were cheating in the public deployment (I created a separate deployment for family and friends).

The core of this feature is in the following code block. It is straightforward and contains little logic. Next year, I may refine it further and involve some scoring curve.

// Calculate time elapsed since the question started
const elapsedTimeInSeconds = state.currentQuestionStartTime
? Math.floor((Date.now() - state.currentQuestionStartTime) / 1000)
: 0;
// Calculate the score for a correct answer after time reduction
const scoreAfterTimeReduction = isCorrect
? Math.max(25 - elapsedTimeInSeconds, 1)
: 0;

Merry Christmas!

Share:

Spotted a typo or want to leave a comment? Send feedback

Stay up to date

Subscribe to my newsletter to stay up to date on my articles and projects

© Lloyd Atkinson 2024 ✌

I'm avaliable for work 💡