I have following code & output. I don't understand why the function is receiving incorrect argument. Please provide pointers.
var tempAccounts = [];
var i;
for (i = 0; i < accountIDs.length; i++) {
var accountID = accountIDs[i];
console.log("Log1:" + accountID);
tempAccounts.push(function(callback){createTempAccount(accountID, callback)})
}
async.parallel(tempAccounts, function (error, results) {
if (error) {
sendError(error, "error creating temp acounts", res, logTag);
} else {
res.set('Content-Type','application/json');
res.send(200, {});
}
});
function createTempAccount(accountID, callback)
{
console.log("Log2:" + accountID);
...
}
Output:
Log1: 1234
Log1: abcd
Log2: 1234
Log2: 1234
What could be the issue here?