I have a simple script that emails the results of a Google Drive form submission. One of the questions in the form has multiple choice checkboxes. I am using e.namedValues to grab the array of answers so that I can email them, like this:
var multiple = e.namedValues['Multiple Choice Question'].toString();
And the result that gets emailed is this:
Answer 1, Answer 2, Answer 3
But I would like the result to be formatted like this:
Answer 1
Answer 2
Answer 3
Instead of separated by commas. Is there any way to do this?
Use JavaScript String's split function
var multiple = e.namedValues['Multiple Choice Question'].toString();
var choicesSelected = multiple.split(',');
multiple ='';
for(var i in choicesSelected){
multiple += choicesSelected[i] + '\n' ;
}
for (var i in multiple){
Logger.log(multiple[i]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With