-2

For example if we have a list of topics and each topic has a list of questions and later on i want to iterate through all the questions..

2
  • How about a loop?
    – str
    Apr 25, 2018 at 6:29
  • Is the list an array, or something else, like HTML elements? Apr 25, 2018 at 6:29

1 Answer 1

1

You could use an array with objects for topics and inside an array for questions.

[
    {
        topic: 'Timetravel',
        questions: [
            'In Films?',
            'In Books?',
            // more questions
        ]
    },
    // more topics
]

Not the answer you're looking for? Browse other questions tagged or ask your own question.