Google Apps Script Typeerror: Cannot Call Method "substring" Of Undefined
I have a google form that when submitted calls an 'on form submit' function that includes javascript .substring(start,finish) method. The strange thing is that in my testcode it w
Solution 1:
no pro here per se, but I think I have a hunch on what the issue is.
vararray = ["aaa", "bbb", "ccc"];
for (var i = 0; i <= array.length; i++) {
console.log(array[i]);
}
See when running the above code, I'll get a console.log at the end with undefined
,
due to the i <= array.length
.
Running a string method like .substring
on undefined
throws the error.
Change the <=
to a <
and you should be good to go.
Post a Comment for "Google Apps Script Typeerror: Cannot Call Method "substring" Of Undefined"