Mask
Mask

Reputation: 573

Single string to array JavaScript

I have selected a range from google sheet. When I select a column it usually becomes array. but when I selected a row it became single string.

How do I solve this? Mentioned below is my code:-

dMatch = sheet.getRange("A2:CE2").getValues();

This coverts the row into a single string array which I don't want.

I tried split method but it throws some error.

dMatch = dMatch.split(",");

Upvotes: 0

Views: 47

Answers (1)

seunggabi
seunggabi

Reputation: 1822

  1. Object to String.
  2. Split comma(,)
dMatch = sheet.getRange("A2:CE2").getValues();
dMatch = JSON.stringify(dMatch).split(",");

Upvotes: 1

Related Questions