I am working on creating a question and answer catalog that allows me to select questions along with their respective answer options from a String Array. However, I encounter an error when trying to assign this.currentQuestion with the question from the catalog, as well as with the answers.
TS2740: Type 'Function' is missing properties like pop, push, concat, join, and more from type 'string[]'.
Below is the code snippet:
data() {
return {
question0: "What is 1+1?",
answers0: ["2", "3", "1", "4"],
questionCatalogue: [this.question0],
answerCatalogue: [this.answers0],
currentQuestion: "",
currentAnswers: ["", "", "", ""]
};
},
methods: {
initNewQuestion: function() {
this.currentQuestion = this.questionCatalogue[0];
this.currentAnswers = this.answerCatalogue[0];
}
},
I expected that calling for this.questionCatalogue[0] would provide me with this.question0 which is a String, allowing me to assign it to this.currentQuestion. Why does it not work as expected?