Calvin Gaunce
Calvin Gaunce

Reputation: 366

Combining Strings

I am new to Google Apps Script and am trying to combine a series of strings. I have two strings that need to go before and after an inputted cell.

if B4 = "string2" the result of the following line should be "string1 string2 string3" . "string1 " + "B4" + " string3"

String1 and string3 will always be the same so I can set them each to a variable, but I don't know how to concatenate them together. They need to be combined and outputted to a cell in Sheets.

Any help would be greatly appreciated.

Upvotes: 0

Views: 139

Answers (1)

Serge insas
Serge insas

Reputation: 46794

Strings are very easy to assemble in JavaScript, simply add them using +

From your example :

"string1"+" "+string2+" "+"string3"

Alternatively you can use the .concat method that does exactly the same.

Upvotes: 1

Related Questions