title: array loop return undefined
body: <p>i'm creating loop using for each to call multiple API,but return undefined when display on console and html. Please help because i cant see my mistake.</p>
  
  <pre><code>var i, len;
  var a = ["1", "2", "3", "4"];
  var api_scan = [];
  var total_scan = [];
  var jsonData;
  for (i = 0; i &lt; a.length; i++) {
  
      api_scan[i] = '/api/v1/file/?folder_id='+a[i];
      console.log(api_scan[i]);
  
      function updateData() {
  
  
          jsonData = $.ajax({
              url: api_scan[i],
              dataType: 'json',
          }).done(function (results) {
              total_scan[i] += results.meta.total_count;  
  
          });
          console.log(total_scan[i]);
  
          total = total + total_scan[i];
  
          $('#total').empty(total);
          $('#total').append(total);
          }
      }
  </code></pre>
  
  <p>Thanks for helping.     </p>