Sample code in Google Apps Script
function myFunction(n) {
Logger.log(n); /* expected output: "n" */
Logger.log(n.length) /* expected output: 1 */
return n;
}
Logger.log(myFunction("n")); /* expected output: "n" */
Execution log
21.35.48 Info n
21.35.48 Info 1.0
21.35.48 Info n
21.35.48 Info null
21.35.48 Error TypeError: Cannot read property 'length' of undefined myFunction @ Test.gs:3
Granted I come from a Python background and this is my first project in Javascript, however I don't have a single idea on why the log shows TypeError. In my project, I can't read the length of 'n' and always quits with error.
Any help is much appreciated!