Skip to content

Instantly share code, notes, and snippets.

@phillypb
Created February 13, 2023 10:31
Show Gist options
  • Save phillypb/99a12958aca5cb8fcad14c17a483a35d to your computer and use it in GitHub Desktop.
Save phillypb/99a12958aca5cb8fcad14c17a483a35d to your computer and use it in GitHub Desktop.
function getFormData(e) {
// get all Form responses
var formValues = e.namedValues;
// get response to specific question
var pizzaTopping = formValues["Favourite Pizza Topping"][0];
console.log("pizzaTopping is: " + pizzaTopping);
// use JavaScript 'includes' to match text
if (pizzaTopping.includes("Chicken")) {
console.log("Likes Spicy Chicken");
} else {
console.log("Does not like Spicy Chicken");
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment