'How to create a script to split and rejoin words in Google Sheets?
I am trying to write an Apps Script script in Google Sheets to split a cell containing words and re concatenate them in a different format. There may be any number of words in the input cell.
Input in cell A1: cat, dog, mouse, rat
Output in cell B2 : "CAT", "DOG", "MOUSE", "RAT"
I cannot get the for loop correct
function tags(data) {
array1 = data.split(", ");
a =[]
for (i=1; i<21; i++){
a = a + char(34) + i + char(34)
return a
}
}
Solution 1:[1]
function tags(data) {
data = data.toUpperCase().split(",");
for (var i = 0; i < data.length; i++)
data[i] = ('"' + data[i] + '"');
return data.join(", ");
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
