Last active
February 28, 2018 06:03
-
-
Save sota1235/1efe9900074a26e8a927c3a31857eb51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Please pass `names` and `foods` from Zapier | |
// If you want to filter by food name, plz pass `specificFood` from Zapier | |
const names = inputData.names; | |
const foods = inputData.foods; | |
const specificFood = inputData.specificFood; | |
const delimitor = ','; // If you want to change delimiter, fix this line | |
const nameList = names.split(delimitor); | |
const foodList = names.split(delimitor); | |
let outputText = 'Name\tFood Restriction'; // Headline | |
for (var i = 0; i < nameList.length; i++) { | |
const name = nameList[i]; | |
const food = foodList[i]; | |
// If name is empty, stop processing | |
if (name === '') { | |
break; | |
} | |
// Filter by specific food name | |
if (specificFood && food !== specificFood) { | |
continue; | |
} | |
outputText = outputText + "\n" + `${nameList[i]}\t${foodList[i]}`; // Row | |
} | |
// You can get value named `listText` on Zapier | |
output = [{ | |
listText: outputText, | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment