空值应用程序脚本 google 表单

Empty Values apps script google forms

我有一个 google 表单的触发器 onFormSubmit。我想知道某个特定的下拉列表是否有答案。假设我有以下形式的代码和我的形式中名称为 Country2

的下拉列表
    function onFormSubmit(e) {
    var AnswerObject = e.namedValues();
    var NumCountries = 1;
    if (namedValues("Country2") != // something goes here {
         NumCountries++;
   }

这个值应该是 "" 或 null 还是其他?

来自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.

考虑到以上情况,尝试类似的方法:

if (namedValues("Country2")) {
     NumCountries++;
}