Spreadsheet - Google App Script [string split function]

Viewed 112649

Just wanted to verify some thought regarding split function. I have constructed a simple code.

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

array1 = string1.split(",");

The problem is based on this kind of coding for example in flash. The string1 will split all "," then transfers it to the array1 in this format ["A","B","C", "D"]. Is this kind of concept similar to Google Spreadsheet - GAS? If yes can you site some example? Thanks a lot guys.

P.S: When I tried splitting the "," it only returns the value "A B C D" as a single element.

Thanks, Nash :)

2 Answers

J.Doe, I cannot submit a comment either, but your problem here is that if you get the value from a form, its type can be an object instead of a string. Hence you are getting the error of no function in object.

You can go around this by converting those objects to strings this way:

objectPretendingString = JSON.stringify(objectPretendingString) //becomes a string
Related