Using an Array of Objects to Store Quiz Questions/Answers For a quiz web app, I decided the best way to store quiz questions, answers, and other user data related to the question was to use an array of objects for the quiz. I'm not sure if this is the best way to go about it since static information such as the questions and answers will be mixed with user data.

Each object in the array contains the quiz question, answer, if the user has enabled the question, and if the question has already been asked during the quiz session.

During a quiz session I wish to ask all questions that are enabled and haven't been asked yet. My script works but I am concerned it is inefficient (with a bank of 1000+ questions)? Is it alright to store user data with my quiz questions? Will this make adding additional questions down the road more difficult? Can I improve what I have or should I look for a different approach?

My script: JS Bin: http://jsbin.com/owehix/1/edit

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;script&gt;
window.onload = function() {

    /////////////////////////////////////////////////
    // CREATE SAMPLE QUIZ ARRAY TO USE IN EXAMPLE //
    /////////////////////////////////////////////////

    // Quiz constructor
    function quizConstructor(question, answer, enabled, asked) {
        this.question = question;
        this.answer = answer;
        this.enabled = enabled;
        this.asked = asked;
    }

    // Create quiz array
    var quiz = new Array();

    // All quiz questions and answers
    quiz[0] = new quizConstructor("Montgomery", "Alabama", false, 0);
    quiz[1] = new quizConstructor("Juneau", "Alaska", true, 0);
    quiz[2] = new quizConstructor("Phoenix", "Arizona", true, 0);
    quiz[3] = new quizConstructor("Little Rock", "Arkansas", false, 0);
    quiz[4] = new quizConstructor("Sacramento", "California", true, 0);
    quiz[5] = new quizConstructor("Denver", "Colorado", false, 0);
    quiz[6] = new quizConstructor("Hartford", "Connecticut", false, 0);
    quiz[7] = new quizConstructor("Dover", "Delaware", false, 0);
    quiz[8] = new quizConstructor("Tallahassee", "Florida", false, 0);
    quiz[9] = new quizConstructor("Atlanta", "Georgia", true, 0);

    /////////////////////////////////////////////////
    // END: CREATE SAMPLE QUIZ ARRAY TO USE IN EXAMPLE //
    /////////////////////////////////////////////////


    // Find the number of questions that the user has enabled
    var numEnabled = 0;

    for (var i = 0; i &lt; quiz.length; i++) {
        if (quiz[i].enabled == true) {
            numEnabled++;
        }
    }


    // Ask all enabled questions in random order
    for (var i = 0; i &lt; numEnabled; i++) {

        // Find random question that hasn't been asked yet
        do {

            var randomNum = Math.floor(Math.random() * quiz.length);

        } while (quiz[randomNum].enabled == false || quiz[randomNum].asked == 1);

        // Ask question
        var question = quiz[randomNum].question + " is the capital of which state?";
        document.getElementById("divSolution").innerHTML += "&lt;p&gt;" + question + "&lt;/p&gt;";

        // Mark question as asked
        quiz[randomNum].asked++;
    }
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div id="divSolution"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
How you're making the questions really looks ugly. How about this way?

var quiz = [{
    question: "Montgomery",
    answer: "Alabama",
    enabled: false,
    asked: 0
},{
    question: "Juneau",
    answer: "Alaska",
    enabled: true,
    asked: 0
}, {} /* ... */ ];

// Now instantiate every quiz
quiz = quiz.map(function(el) {
    return new quizConstructor(el.question, el.answer, el.enabled, el.asked);
});


Now if you're not doing anything more with your quizConstructor object, you can just as well use plain objects. (What's done before instantiating every quiz up there.)