title: Looking for distance between multiple points in a googlesheets script
body: <pre class="lang-js prettyprint-override"><code>// adapted from developers.google.com/apps-script/quickstart/macros
  function drivingDistance(origin, waypoint, destination) {
      var directions = getDirections_(origin, destination);
      return directions.routes[0].legs[0].distance.value;
  }
  
  function getDirections_(origin, waypoint, destination) {
      var directionFinder = Maps.newDirectionFinder();
      directionFinder.setOrigin(origin);
      directionFinder.addWaypoint(waypoint);
      directionFinder.setDestination(destination);
  
      var directions = directionFinder.getDirections();
      if (directions.routes.length == 0) {
      throw 'Unable to calculate directions between these addresses.';
      }
      return directions;
  }
  </code></pre>
  
  <p>This script originally checked column A for origin and then checked column B for destination.  I was trying to use the addWaypoint function to add a 3rd point, but have been unsuccessful.  I read through the API and tried a few different variations, but am afraid that I was again unsuccessful. How do I add multiple destinations or waypoints</p>