I am working on a little exercise with the Javascript Vue.js Framework. I cut the following code to show my problem. I have two variables with no value in the data part. I try to edit the two variables in a method.
I stored two number values in a array called "counter".
I stored the two variables (a and b) from the data part in an array called "values" (with the "this") before.
Then I use two for loops to edit them. But I can't get access to the variables a and b, when they are stored in the array "values". I think my problem is the Array "values". If i change the values[i] in the last for-loop in "this.a", it works. But not if I want to get access with the variables stored in the array.
I think it is a JavaScript problem but I don't know, how I can solve it. I already looked up some similar questions in stack Overflow but I can't transfer the solutions to my case.
// Vue.js Model-Part
data: {
a = '';
b = '';
}
//A snippet out of the method-part
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] += "*";
};
thiskeyword. When you console.logthis.a, what do you get?