I am trying to convert calendar dates to fiscal dates. I've been successfully able to do all that. My problem is trying to write the fiscal date values back into the spreadsheet. Here is the code:var dates = [];var fyear = [];var fiscalDates = [];for (var x=1; x < getLastRows;x++) {    dates[x] = getFiscalValues[x][9];    fyear[x] = getFiscalValues[x][37];    fiscalDates[x] = [];    if (fyear[x] == ) {      var fiscalRowNumber = fiscalUpdate(dates[x]);      var openFiscalSS = SpreadsheetApp.openById(fiscalRowNumber[0]);      var openFiscalYear = openFiscalSS.getSheetByName(fiscalRowNumber[2]);      var fiscalCols = openFiscalYear.getDataRange().getLastColumn();      var fiscalValues = openFiscalYear.getRange(fiscalRowNumber[1],1,1,fiscalCols).getValues();       // this array now contains all the values required for the current fiscal      fiscalDates[x][0] = fiscalRowNumber[2];      fiscalDates[x][1] = fiscalValues[0][0];      fiscalDates[x][2] = fiscalValues[0][1];      fiscalDates[x][3] = fiscalValues[0][2];      fiscalDates[x][4] = fiscalValues[0][3];    } // end of if statement that checks if Fiscal year is blank  } // end of the for loop that updates the fiscal dates for each rowvar openTM = SpreadsheetApp.openById(tmFileString);var openTmResponse = openTM.getSheetByName(tmResponses);openTmResponse.getRange(2,40,getLastRows,5).setValues([fiscalDates]);The error I am getting when I attempt to write back the values to the spreadsheet is Incorrect range height, was 1 but should be 132. I checked the values of getLastRows and the length of fiscalDates array - both numbers are the same. I can't seem to figure out what I am doing wrong with the last statement. 
Incorrect range height error in Google script when using setValues
google spreadsheets;google apps script
The particular issue was sorted out in comments, but to have a generally useful answer here I include a helper function for checking whether an array is rectangular. If .setValues(something) throws an error, put checkArray(something) before that line. The function checks whether the argument is a double array in which all rows have equal length. Its output is found in the log, viewable by pressing Ctrl-Enter after running a script.  function checkArray(ar) {  if (ar.constructor !== Array) {    Logger.log('Not an array'); return;  }    var height = ar.length;   if (ar[0].constructor !== Array) {    Logger.log('Not a double array'); return;  }  var width = ar[0].length;  for (var i = 0; i < height; i++) {    if (ar[i].length !== width) {      Logger.log('Not rectangular: row '+(i+1)+' has length '+ar[i].length+' instead of '+width);       return;    }  }  Logger.log('Rectangular of height '+height+' and width '+width);}It would be great if Apps Script itself logged more detailed error messages of this sort, instead of just saying Cannot convert Array to Object[][].