title: Async Library ForLoop
body: <p>I have tried to run this code and get the say.speak commands to run one at a time using the async library. But instead the speak commands all happen at the same time. The console.logs happen in the correct order though! Does anyone know a solution?</p>
  
  <p>The console solution (Time and then event name):</p>
  
  <p>12:00:00 PM</p>
  
  <p>Mach &amp; Matt</p>
  
  <p>4:00:00 PM</p>
  
  <p>Set up help!  Microsoft Social 3.0 Chicago</p>
  
  <p>4:30:00 PM</p>
  
  <p>AV Check - Microsoft Social 3.0 Event Chicago</p>
  
  <p>The code</p>
  
  <pre><code>var api = require('./api.js');
  var say = require('say');
  var async = require('async');
  var S = require('string');
  var i = 0;
  
  api.getEvents(function (err, result) {
      if (err)
          console.log(err);
      else {
          //Intro();
  
          async.times(result.value.length, function (callback) {
              async.series([
                  function (callback) { Time(result.value[i].start.dateTime, callback);},
                  function (callback) { someAsyncTask(result.value[i].subject, callback); ++i;  },
  
  
              ])
          });
  
      }
  
  });
  // do two async series.. one for setup and one for read
  // series 1: time convert, and send result.value[i] to series 2
  // series 2: for loop to read out 
  // optional callback
  
  function Intro() {
      setTimeout(function () {
          say.speak('todays schedule is');
      }, 1000);
  }
  
  function someAsyncTask(event, callback) {
      setTimeout(function () {
          console.log(event);
          say.speak(event);
          // * returning err !== null will abort the execution
          // of all tasks and call finalCallback(err)
          // * result will be appended to the list of results returned to finalCallback()
          callback(/*err=*/null, /*result=*/event);
      }, 2000);
  }
  
  
  function Time(data, callback) {
      var cst = new Date(Date.parse(data));
      var time = cst.toLocaleTimeString();
      setTimeout(function () {
          console.log(time);
          say.speak(time);
      }, 2000)
  
      callback();
  }
  </code></pre>