What ____ Are You?

A personality quiz where the category is a parameter and the answer comes from Wikipedia.

Screenshot of What Are You
The title screen. The blank is a dropdown of categories.

Those "What kind of X are you?" quizzes are everywhere. What sandwich are you. What 90s sitcom character are you. They all have the same shape, a fixed set of multiple-choice questions and a mapping from answers to results. The questions are generic personality questions that could map to anything.

So I built one where the category is a parameter. You pick a topic from a dropdown, the title fills in ("Countries" becomes "What Country Are You?"), and the result is pulled live from Wikipedia.

Where the categories come from

The dropdown itself comes from Wikipedia. On each load I pick 5 of 15 broad root categories (Nature, Science, Food and drink, Organisms, Sports, and so on), fetch their subcategories through the MediaWiki API, keep the short single-word names, shuffle, and show 25. If that turns up too few, a fixed list fills in instead. So the dropdown is different every time you load the page.

The questions and the hash

You get 10 questions drawn from a pool of 500, each with four answers. "What is your relationship with your phone at 2% battery?" is one of them, and "My phone is always at 2 percent. We live here now." is one of its answers. When you finish, I take the index of each answer, multiply it by the question's position from 1 to 10, sum the products, and take the total modulo the number of eligible articles in the category, so the same answers give the same article.

The eligible articles are the first 100 pages in the category by sort key, minus anything with "disambiguation", "list of", "index of", "outline of", or "glossary of" in the title, and anything with a slash or a colon. If the category query fails I fall back to a plain search for the category name. A second call fetches the winning article's intro text and a 500 px thumbnail for the reveal. Because the pool is whatever Wikipedia holds today, the result you got last month can be a different article now.

The Jeopardy theme

There's an mp3 in the repo: the Jeopardy! think music. It starts on your first tap, since browsers won't autoplay audio before a gesture, and its playback rate ramps from 1x at the first question to 3x at the last, in 0.3 second glides so it never jumps. By question 8 it's noticeably frantic.