asyncjs - eachSeries() doesn't iterate through all items in array

Problem

I have the following code which uses async.js

var async = require('async');
var A = [];

for(var i = 1; i < 100; i++)
    A.push(i);

async.eachSeries(A, function(item) {
    console.log(item);
});

I expected this to print numbers from 1 to 100, however when I run this the output is just 1

If I use each() instead of eachSeries() it prints all the numbers, though.

So, why is the code not working while eachSeries() is just a serial version of each()?

Problem courtesy of: Jatin

Solution

The iterator functions needs 2 arguments item and callback, callback must be called once the iteration is complete.

async.eachSeries(A, function(item, callback) {
    console.log(item);
    callback();
});
Solution courtesy of: pNre

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.