I have a custom GAS function that would return 3 string values for each call. Each 3 values will be pushed into an array. So, I have the below values in an array after calling the function for 3 times:-
ArrValues=[["String1","Pattern1","Mesh1"],["String2","Pattern2","Mesh2"],["String3","Pattern3","Mesh3"]];
I want all these values to be listed in gsheet accordingly like below:-
At the moment, I coded as below to get the expected output:-
sheet.getRange(2,4,ArrValues.length,1).setValues(ArrValues.map(ArrValues=>[ArrValues[0]]));
sheet.getRange(2,5,ArrValues.length,1).setValues(ArrValues.map(ArrValues=>[ArrValues[1]]));
sheet.getRange(2,6,ArrValues.length,1).setValues(ArrValues.map(ArrValues=>[ArrValues[2]]));
I also can achieve the same using "for..." loop like below:-
for(i=0;i<ArrValues.length;i++){
sheet.getRange(2,i+4,ArrValues.length,1).setValues(ArrValues.map(ArrValues=>[ArrValues[i]]));}
I would like to know is there any simpler as 1 line code which only will go through the elements once and return all the values in it's own individual column simultaneously, please? I tried below but it doesn't work.
sheet.getRange(2,4,ArrValues.length,3).setValues(ArrValues.map(ArrValues=>[ArrValues]));