I have a trigger onFormSubmit for a google form. I want to know if a particular drop down list has an answer or not. Suppose that I have code of the following form and a drop down list in my form with the name Country2
function onFormSubmit(e) {
var AnswerObject = e.namedValues();
var NumCountries = 1;
if (namedValues("Country2") != // something goes here {
NumCountries++;
}
Should this value be "" or null or something else?
From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else
Any value that is not undefined, null, 0, NaN, or the empty string (""), and any object, including a Boolean object whose value is false, evaluates to true when passed to a conditional statement.
Considering the above, try something like:
if (namedValues("Country2")) {
NumCountries++;
}