title: JavaScript: Manipulate matrix row at index
body: <p>I am trying to solve this problem:</p>
  <p>I seem to get everything EXCEPT: manipulating the row of a matrix at a specific index. The code that I wrote, performs the function at all of the rows, not the specified row.</p>
  <p>Here is the code:</p>
  <pre><code>const solvematrix= (r, c, indices) =&gt; {
      let matrix = new Array(r).fill(new Array(c).fill(0));
  
      for (let i = 0; i &lt; indices.length; i++) {
          // get index values to increase
          let rIdx = indices[i][0];
          let cIdx = indices[i][1];
  
          // modify row matrix in-place ; This is where the Error is
          matrix[rIdx].map((cv, idx, array) =&gt; array[idx]++);
  
          // modify column matrix in-place
          matrix[cIdx].map((cv, idx, array) =&gt; (cIdx === idx ? array[idx]++ : null));
      }
  
      return matrix;
  };
  
  
  solvematrix(2, 3, [[0, 1],[1, 1]])
  Output: [[2,4,2],[2,4,2]]
  Expected: [[1,3,1],[1,3,1]]
  </code></pre>
  <p>As you can in the output above, the values are increased for all the numbers in rows, not just the specific row.</p>