joshlsullivan
joshlsullivan

Reputation: 1500

How to split a javascript array using Google Script

I'm working on a project that outputs a huge array, and I need to clean it up to send in an email. It seems the simplest approach is the split() function, but I can't seem to make it work.

function splitArray() {
var ss = SpreadsheetApp.getActiveSheet();
var row = ss.getLastRow();
var range = ss.getRange(row, 1, 1, ss.getMaxColumns());
var data = range.getValues();
data.split("\n");
Logger.log(data);}

Upvotes: 0

Views: 4362

Answers (1)

Andrew Hall
Andrew Hall

Reputation: 3073

You need to set the return value of data.split("\n"); to something. You are splitting the value successfully but not storing that value anywhwere

Try:

data = data.split("\n");

or

Logger.log(data.split("\n"));

Upvotes: 2

Related Questions