Buzzfeed What State do you Actually Belong In Revealed

Buzzfeed recently released a quiz that has been getting a lot of attention on my Facebook news feed, titled “What State Do You Actually Belong In?“. The quiz consists of 12 sets of 12 questions and then produce an answer of a state that you supposedly closely identify with. According to Buzzfeeed, I belong in Minnesota, which is far too cold and obviously incorrect, so I decided to do some digging to figure out how their quiz system works.

buzzfeed-state-quiz

To view the states that Buzzfeed assigned to each quiz answer, view my What State Do You Actually Belong In Revealed (PDF). To see how I created this file, continue reading…

The Quiz Variable

Buzzfeed has a lot of quizzes on their website, and has generalized the quiz code in the file: User_and_Buzz_concat_header.js. This file is minified, so I copied and pasted the contents into JSBeautifier.org so that I could actually read it. All of the quiz functionality lives in the BF_Quiz function, and “bf_quiz” is the window variable holds instances of quizzes on the page. A quick look in Chrome’s Web Inspector Console reveals that the “What State do you Actually Belong In” quiz instance is stored in “window.bf_quiz.quizes[1]”.

Buzzfeed Personality Quizzes

As far as I can tell, Buzzfeed has 3 types of quizzes: Single Question, Standard, and Personality. The “What State do you Actually Belong In ” quiz is a Personality quiz.

Buzzfeed’s personality quizzes start with a finite number of personalities (the results of the quiz) and assigns a 0-based index to each. For example, personality_index 0 is Alabama, 1 is Alaska, 2 is Arkansas, and so on. The States quiz has 48 personalities, it seems they have left out Arizona and South Dakota for some reason. All of remaining states are in alphabetical order except for Minnesota, which is listed last for some reason.

Next, each answer on the quiz is matched to a personality with the attribute “rel:personality_index” on the question. If you use web inspector, you can see that the first question, “Which of these is your Favorite Fast Food Chain?”, first answer choice “Sbarro”, is contained within a list item element containing rel:personality_index=”29″, which fittingly relates to the personality_index of New York.

Calculating the Results of a Personality Quiz

The calculation of the result for a personality quiz can be found in the BF_Quiz function “this.personality” from User_and_Buzz_concat_header.js.

Buzzfeed’s personality quizzes wait until you have answered all of the questions and then calculate the result. It does this by creating an array with all of the personalities and initializing each personality to 0. For every question that you answered, it gives 1 point to that personality. So if you selected “Sbarro” as your answer to question 0, you will get 1 point towards personality_index 29, which is New York.

After the personalities have been totaled, Buzzfeed starts in reverse order with the last personality_index, and begins searching for the highest number of points for a personality. If two personalities are tied (have the same number of points), it will not update the result, so the personality closer to the bottom of the list will win.

Since the “What State do you Actually Belong In” quiz has 12 questions and 48 possibilities, there is a pretty high chance that all of your answers will be for a different State, meaning that the state with 1 point closest to the bottom of the list will win. Alas, I know why I got Minnesota (it is on the bottom of the list).

Displaying the State/Personality next to the Quiz Question

I wanted to see which State Buzzfeed was associating with each quiz answer, so I whipped up a script to do just that. This entire script can be copied and pasted into the Chrome Web Inspector Console.

Since I like using JQuery selectors, the first thing to do was load JQuery in the Chrome Web Console (source: StackOverflow) on the Buzzfeed quiz page:

var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
jQuery.noConflict();

Next, I iterated through the quiz results in order to display the State name next to each answer choice. Buzzfeed’s code generates the quizzes from HTML DOM elements meaning that the entire quiz result containing images, descriptions, and the state name are stored in the result. I used the US State Full Names (source:RegExLib) to pull just the State name out of the result.

var re=/(Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New\sHampshire|New\sJersey|New\sMexico|New\sYork|North\sCarolina|North\sDakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode\sIsland|South\sCarolina|South\sDakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West\sVirginia|Wisconsin|Wyoming)/

for (var key in bf_quiz.quizes[1].results){
    var state= bf_quiz.quizes[1].results[key].el.innerText;
    var match=bf_quiz.quizes[1].results[key].el.innerText.match(re);
    if (match){
        state=match[0];
    }
    jQuery('li[rel\\:personality_index='+key+']').append('<div style="font-weight:bold; color:#F00;">'+state+'</div>');
}

Comments on Buzzfeed’s Quiz Algorithm

Buzzfeed’s quiz algorithm is extremely basic. I’m guessing that the backend application to generate personality quizzes for Buzzfeed takes pretty much no HTML or JavaScript knowledge and simply allows the creator to create questions, create answers, and link questions to answers.

This quiz is kind of disappointing because there are 48 states listed and only 144 different quiz options to choose from, meaning each state is only represented in about 3 answer choices on average.

That being said, a plethora of my friends posted the results to this quiz on Facebook, so Buzzfeed is doing something right: entertaining people. My recommendation would be to take your quiz result with a grain of salt and don’t quit your job and move solely based on the result