title: Javascript: split string into 2d array
body: <p>I have a string of month and years:</p>
  
  <pre><code>var months= "2010_1,2010_3,2011_4,2011_7";
  </code></pre>
  
  <p>I want to make this into a 2d array with the year in the first position of each array and the month in the second position. In other words, I want to end up with this:</p>
  
  <pre><code>var monthArray2d = [[2010,1],[2010,3][2011,4],[2011,7]];
  </code></pre>
  
  <p>The way I do this currently is:</p>
  
  <pre><code>//array of selected months
  var monthArray = months.split(",");
  
  //split each selected month into [year, month] array
  var monthArray2d = new Array();
  for (var i = 0; i &lt; monthArray.length; i++) {
      monthArray2d[i] = monthArray[i].split("_");
  </code></pre>
  
  <p>Is there a way to condense that code so that I never need to use the <code>monthArray</code> var?</p>