I have a for loop. The purpose of the loop is to index a one dimensional array of 5 numbers within a two dimensional array, then add the numbers in that array together and place it in on another sheet (testSheet). It's returning text like "0,45,,,40". The program works fine, other than it's not adding the numbers together. I'm guessing this is because some of the cells are null and it's not recognizing them as numbers.
for (var i=0; i < arrTarget.length; i++){
//find Row
var row = arrSource.indexOf(arrTarget[i]);
var numArr = shrinkLog.getRange(row+3,4,5).getValues();
//add units in an array
var sum = numArr.reduce(function(a,b){return a+b;},0);
//execute
var testsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("test Sheet");
testsheet.getRange(i+1,1,1,1).setValue(sum);
}
Can someone help how I get the program to recognize the null cells as the number 0?