Reputation: 315
I have a very simple prompt that outputs elements from an array:
const arr = [1, 2, 3, 4, 5, 6];
function alertMessage() {
SpreadsheetApp.getUi().alert(`List of numbers: ${arr}`);
}
alertMessage();
The message currently reads like this:
List of numbers: 1,2,3,4,5,6
However, I would like it to create a new line after each element (with no commas), so it would look like the below example. What would be the best way to do this?
List of numbers:
1
2
3
4
5
6
Upvotes: 0
Views: 30
Reputation: 201603
It seems that in your script, arr
is an array. So, how about the following modification?
SpreadsheetApp.getUi().alert(`List of numbers: ${arr}`);
SpreadsheetApp.getUi().alert(`List of numbers: \n${arr.join("\n")}`);
SpreadsheetApp.getUi().alert(
List of numbers: \n${arr.join("\n\n")});
Upvotes: 2