Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
When passing a variable to function, variable.length return a TypeError

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!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!