title: Getting row and column values from 81-element indexed array
body: <p>I have an indexed JavaScript array which contains exactly 81 element. These elements will create 9x9 grid (similar to the Sudoku), but for now I need to find the way, how to efficiently get row and column values from that array.</p>
  
  <p>For example, function <code>getRow(2)</code> have to return indexed array of 9 values, placed in the second row of the 81-element array, and the <code>getColumn(2)</code> have to work by analogy.</p>
  
  <p>Currently my <code>getRow()</code> function looks like this:</p>
  
  <pre><code>function getRow(rowId){
  
      // Indexes for every row in the 81-element array
      var rowIndexes = {
          1: [0,1,2,3,4,5,6,7,8],
          2: [9,10,11,12,13,14,15,16,17],
          3: [18,19,20,21,22,23,24,25,26],
          4: [27,28,29,30,31,32,33,34,35],
          5: [36,37,38,39,40,41,42,43,44],
          6: [45,46,47,48,49,50,51,52,53],
          7: [54,55,56,57,58,59,60,61,62],
          8: [63,64,65,66,67,68,69,70,71],
          9: [72,73,74,75,76,77,78,79,80]
      };
  
      // New array for row values
      var rowValues = new Array();
  
      for(var i=0; i &lt; 9; i++){
          // Getting row value from 81-element array
          rowValues.push(GRID_ARRAY[rowIndexes[rowId][i]]);
      }
  
      return rowValues;
  
  }
  </code></pre>
  
  <p>So, is there more dynamic and more optimal method how calculate both row and column values according to the specified row/column ID?</p>
  
  <p>Thanks!</p>