I am currently facing an issue where I need to iterate over an array containing promises. My goal is to multiply all the values in the array by 2 and then return the updated array:
var Bluebird = Promise.noConflict();
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
function processArray(arr) {
return Bluebird.each(arr, function(value) {
return value = value * 2;
}).then(function(updatedArr) {
console.log('--done--');
console.log(updatedArr);
// should return [2, 4, 6, 8, 10, 12, 14, 16, 18];
});
}
processArray(arr);
However, my function seems to be returning the original array instead of the updated one. Can someone please assist me with this? Here's a link to my fiddle for reference:
http://jsfiddle.net/mpo4yrmu/71/
Thank you in advance!