Objective: I want to set all values of the array to (valueofIndex + 1) and log the new array in the end.
**EDIT:**
This DOESNT WORK:
var async = require('async');
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function attemptAtAsyncEach (arr) {
return async.map(arr, function (member, callback) {
callback(null, member + 1);
}, function (err, results) {
return results;
});
}
console.log(attemptAtAsyncEach(arr));
THIS WORKS:
var async = require('async');
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function attemptAtAsyncEach (arr) {
return async.map(arr, function (member, callback) {
callback(null, member + 1);
}, function (err, results) {
console.log( results);
});
}
attemptAtAsyncEach(arr);
If I return results instead of console.log in the callback, why does it show undefined?