Answer the question
In order to leave comments, you need to log in
How to correctly implement an array of objects in TypeScript?
Hello.
Before the main question, I would like to ask a side question.
The purpose of the task is to make a quiz. That is, there is a question and n-th number of answer options.
To store all questions and quizzes, I'm going to use something like this
const questions: {question?: string, option1?: string, option2?: string, option3?:string, option4?: string}[] = [
{
question : "text of question 1",
option1: "opt1",
option2: "opt2",
option3: "opt3",
option4: "opt4"
},
{
question : "text of question 2",
option1: "opt1",
option2: "opt2",
option3: "opt3",
option4: "opt4",
},{},{},{},{},{},{},{},{}
];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question