Dev.to WebDev 🛠 Dev 👁 0 📖 1 min read

I built a 25-question Seven Deadly Sins quiz. Here’s how it scores and shares results.

A teammate gets praised for a project you helped finish. How would you react? That’s the kind of everyday situation behind my 7 Deadly Sins Test. The site is a short self-reflection quiz inspired by the seven deadly sin

A teammate gets praised for a project you helped finish. How would you react? That’s the kind of everyday situation behind my 7 Deadly Sins Test.

The site is a short self-reflection quiz inspired by the seven deadly sins. You answer 25 questions with four choices each and get a percentage breakdown for pride, greed, lust, envy, gluttony, wrath, and sloth. You can read a guide to your highest-scoring category or share it with a friend. There’s also an anime edition that maps the leading category to a character from The Seven Deadly Sins. The quiz is free and requires no account.

Keeping the full result out of the share link

The quiz runs in the browser and saves your answers in sessionStorage, so refreshing in the same tab brings you back to the question you were on.

After the last answer, the quiz passes the seven raw scores to the result page in a URL fragment. The page moves the scores into history.state and clears the fragment from the address bar. That lets the page restore the full breakdown if you refresh it.

The copy button generates a new link with just the leading category and its percentage in the standard quiz. That’s enough for a friend to see what you got while keeping the full breakdown in your browser.

When a tie looks like 30% vs. 29%

Each answer adds one or two points to one category. To make the seven displayed percentages add up to exactly 100%, the quiz rounds them down first, then gives the leftover percentage points to the categories with the largest fractional remainders.

For example, raw scores of 8, 8, 4, 3, 2, 1, 1 display as 30%, 29%, 15%, 11%, 7%, 4%, 4%. Both categories with eight points still tie for first. The ranking uses raw scores, and the result page calls out the tie.

How would you display those two bars so the tie is obvious at a glance?

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.