Q:

async.parallel() - last function not being called

For some reason the 'yyyyyyyyy' string is never printed when I use async.parallel() as per below. Why is this? I thought that the last function would be called once the other two have been called.
var async = require('async');
async.parallel([
    function() {
        console.log('xxxxxxxxxxx');
    },
    function() {
        console.log('ccccccccccc');
    }
], function(err, results){
    console.log('yyyyyyyyy');
});

A:

Every function passed in the first parameter to async.parallel should take a callback that it calls when its done so async knows that it has completed:
var async = require('async');
async.parallel([
    function(callback) {
        console.log('xxxxxxxxxxx');
        callback();
    },
    function(callback) {
        console.log('ccccccccccc');
        callback();
    }
], function(err, results){
    console.log('yyyyyyyyy');
});

If an error happens in one of the functions, it should call the callback with
callback(err);

so that async knows an error has occurred and it'll immediately call the last function.

