I'm currently working on a project involving the JavaScript Vue.js Framework. I've encountered an issue that I need help with, and I've included some code below to illustrate my problem. In the code, I have two variables in the data section that don't have values assigned to them. My goal is to update these variables within a method.
I've initialized an array called "counter" to store two number values.
Prior to running the for loops to modify the variables, I stored the values of variables (a and b) from the data section in an array named "values" using "this".
However, I'm facing a challenge in accessing the variables a and b when they are stored in the "values" array. I suspect that the issue lies with the "values" array. If I change values[i] in the last for loop to "this.a", it works fine. But, I'm unable to access the variables stored in the array.
This seems like a JavaScript-related issue, and I'm not sure how to resolve it. I've tried looking for similar problems on Stack Overflow but haven't been able to apply the solutions to my specific case.
// Vue.js Model Section
data: {
a = '';
b = '';
}
//Snippet from the method section
var one = 13;
var two = 14;
counter = [one, two];
values = [this.a, this.b];
for(var i = 0; i < counter.length-1; i ++){
for(var position = 0; position < counter[i]; position ++){
values[i] += "*";
};