code: function crop(data, rows, cols, nRows, nCols) {
  
      if (rows === nRows && cols === nCols) {
          //Do nothing. Returns the same input!!! Be careful
          return data;
      }
  
      var output = new Array(nCols * nRows);
  
      var shiftR = Math.floor((rows - nRows) / 2);
      var shiftC = Math.floor((cols - nCols) / 2);
      var destinyRow, sourceRow, i, j;
      for (i = 0; i < nRows; i++) {
          destinyRow = i * nCols;
          sourceRow = (i + shiftR) * cols;
          for (j = 0; j < nCols; j++) {
              output[destinyRow + j] = data[sourceRow + (j + shiftC)];
          }
      }
  
      return output;
  }
docs: Crop the given matrix to fit the corresponding number of rows and columns