passing a string to a function to get used as an object in javascript/jquery
<p>I have a loop that calls a <code>JSON</code> array as an object. I want to itterate through the array to find items called match, the match names are called - match1, match2 etc. </p>

<p>It works instead of using the created <code>var</code> <code>finalM</code> <code>i</code> type <code>match1, match2</code> etc. </p>

<pre><code>    var theObject = data; // get json data 
    var i;
      for (i = 0; i &lt; theObject.length; i++){
          var add = i + 1 ;
          var finalM = "match"+ add; 
          $('.someDiv').append(
              theObject[i].finalM.someVal
          );
    }
</code></pre>

<p>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. </p>