title: Debugging a custom function in Google Apps Script
body: <p>I am trying to create my first custom function for a Google Spreadsheet in Apps Script and I am having a hard time using the debugger.</p>
  
  <p>I am working on the <a href="https://developers.google.com/apps-script/quickstart/macros?hl=de" rel="noreferrer">custom function demo code</a> from the Google documentation and I have set a breakpoint in the custom function <code>drivingDistance(origin, destination)</code> that is used in a cell of my spreadsheet. The problem I have is, that that the debugger shows the parameters that are passed into the function as being <code>undefined</code>. The content of any other variables that are created during execution is displayed correctly though (as long as they do not depend on the input parameters).</p>
  
  <p>Funny thing is that although the input parameters are displayed as undefined, the function's calculations succeed, so this seems to be a debugger issue. Unfortunately this problem prevents me from successfully learning to create and debug own code (as I will have to work with complex input parameters). </p>
  
  <p>I have a feeling that the problem is connected to the server-side execution of Apps Script, so I tried to log the input parameters using the Logger class and I also tried to copy these variables into new local variables. But all I came up with was <code>undefined</code>.</p>
  
  <p>Another strange hint is, that <code>typeof</code> of the parameters returns <code>String</code>. But getting the length of them throws an error and trying to concatenate them with another string returns the string "undefined" (see my screen dump).</p>
  
  <p><a href="https://i.stack.imgur.com/MA19m.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MA19m.png" alt="debugger screenshot"></a></p>
  
  <p>I am looking for insights about what is going on here.</p>