I have a loop that calls a JSON
array as an object. I want to itterate through the array to find items called match, the match names are called - match1, match2 etc.
It works instead of using the created var
finalM
i
type match1, match2
etc.
var theObject = data; // get json data
var i;
for (i = 0; i < theObject.length; i++){
var add = i + 1 ;
var finalM = "match"+ add;
$('.someDiv').append(
theObject[i].finalM.someVal
);
}
I know its something to do with the scope of the string, but can't find a good example to help me with the problem.