Skip to content

Instantly share code, notes, and snippets.

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]);
var value = values.length > 0 ? values[Math.floor(Math.random()*values.length)] : "まだ投稿されていない";
var output = ContentService.createTextOutput(value);
return output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment