Spreadsheet - Google Script Application [line breaking function]

Just wanted to test some thoughts on the split function. I created simple code.

var array1 = [{}];
var string1 = "A, B, C, D";

array1 = string1.split(",");

The problem is based on this kind of encoding, for example, in flash. Line 1 will split everything ","and then translate it to array 1 in this format ["A","B","C", "D"]. Is such a concept similar to Google Spreadsheet - GAS? If so, can you post an example? Many thanks to the guys.

PS: When I tried to split ",", it returns the value "A B C D"as only one element.

Thanks, Nash :)

+5
source share
1 answer

, Logger.log(array1); , : [A, B, C, D]. , split, : string1.split(", ");

function myFunction() {
  var array1 = splitTest();
  Logger.log(array1);
}

function splitTest() {
  var array1 = [{}];
  var string1 = "A, B, C, D";

  array1 = string1.split(", ");
  return array1
}
+8

All Articles