问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/26888885/combining-strings