Within my Angular project, I've created a class:
export class Test {
mcq: { question: string, options:string[]}[] = [];
} //outline of an object containing a question and an array of strings
In another component where I import this class, I want to create an object from the Test class. Here's how I did it:
let exampleTest = new Test();
exampleTest.mcq = [{ question: 'any question?', options[0]: 'a', options[1]: 'b', options[2]: 'c', options[3]: 'd'}]
The options[0]
part within exampleTest.mcq
is causing an error.
I've been spending the last hour trying to figure out what I'm doing wrong. I even attempted
exampleTest.mcq.options[0] = 'a';
but it still doesn't work.