Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Random roulette app for GoogleSpreadsheet(GAS). Deploy and HTTP GET!
function doGet(e) {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName("フォームの回答 1");
var range = sheet.getRange("B2:B");
var values = range.getValues();
values = values.filter(String).map(v=>v[0]);
// console.info(values);
var value = values.length > 0 ? values[Math.floor(Math.random()*values.length)] : "まだ投稿されていない";
// console.info(value);
var output = ContentService.createTextOutput(value);
output.setMimeType(ContentService.MimeType.TEXT);
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment