0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Best approach for scoring logic in a small client-side quiz (vanilla JS, no framework)

0
Posted at

I'm building a small interactive quiz feature for a content site I run (https://www.crabguide.com/types-of-hermit-crabs/), the quiz asks a few multiple-choice questions and recommends a result category based on the combined answers, similar to a basic "which type are you" format.

I'm using plain JavaScript, no framework, since the rest of the site is WordPress and I don't want the overhead of a full build pipeline for one small feature.

My current approach is a simple weighted-scoring object where each answer adds points to different result categories, and the highest score at the end determines the result. This works for a small number of questions, but I'm wondering if this pattern breaks down or gets hard to maintain as more questions/branches get added.

Is a weighted-scoring approach generally considered fine at small scale, or is there a cleaner pattern (state machine, decision tree, etc.) that's worth adopting early even for something this simple? Interested in hearing from anyone who has built something similar without a framework.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?