I'm currently working on a quiz application using Javascript and I need some advice on how to effectively nest arrays/objects. While I've nested arrays before at a basic level, this project requires more complexity.
The quiz will consist of 5 questions with multiple answers, each associated with a specific point value. Once the quiz is completed, an average of points will determine a result type such as 'You mostly ticked A's', 'You mostly ticked B's', similar to magazine quizzes.
My proposed structure looks like this:
var quizList = {
"question": "What's your favorite Color",
"answers": [
["a","Blue","2"],
["b","Green","4"],
["c","Red","6"],
["d","Orange","8"]
],
"question": "What's your favorite Animal",
"answers": [
["a","Dog","2"],
["b","Cat","4"],
["c","Caterpillar","6"],
["d","Donkey","8"]
]
};
Is my approach correct? And if so, how do I access the various array elements?