Get the last response from a Google Form
<p>I am working on a script to get the last form submission. I found the vanilla example online...</p>

<pre><code>function onSubmit() {
  // Open a form by ID and log the responses to each question.
 var form = FormApp.openById('1G3e4FTYlsJUl5mKX2v1pYWauG1FO5IUPDIOI6P4hUoA');
 var formResponses = form.getResponses();
 for (var i = 0; i &lt; formResponses.length; i++) {
   var formResponse = formResponses[i];
   var itemResponses = formResponse.getItemResponses();
   for (var j = 0; j &lt; itemResponses.length; j++) {
     var itemResponse = itemResponses[j];
     Logger.log('Response #%s to the question "%s" was "%s"',
         (i + 1).toString(),
         itemResponse.getItem().getTitle(),
         itemResponse.getResponse());
   }
 }
}
</code></pre>

<p>I have modified this to...</p>

<pre><code>function onSubmit() {
  // Open a form by ID and log the responses to each question.
 var form = FormApp.openById('1G3e4FTYlsJUl5mKX2v1pYWauG1FO5IUPDIOI6P4hUoA');
 var formResponses = form.getResponses();

 var last_response = formResponses[formResponses.length - 1];
  Logger.log(last_response.val)
}
</code></pre>

<p>When I view the log for the script above I get <code>undefined</code>. How do I output the value of last_response?</p>