When running the split function on an array column in Google Apps Script, it generates multiple columns with varying numbers. Some rows may have 6 columns and others only 4.
I want to adjust the output array to ensure all rows have an even number of columns. This means extending those rows with fewer columns by adding empty spaces in the extra columns.
How can I incorporate this into my equation? Currently, I am using the following formula:
var splitarray = originalarray.map(function(row){ return row[0].split(" ") });
If I log this variable, the result might look like this:
[[1,2,3],
[1,2,3,4]]
However, I would like the output to be (in this example):
[[1,2,3,],
[1,2,3,4]]
This way, all arrays will have the same number of columns.
P.S. I am aware that this modification could be made within the spreadsheet itself, but this specific task is part of a larger script operation I am working on.