I have this code:
var arrMultiplication = function(arr1, arr2) {
return new Promise(function(resolve, reject) {
if ( arr1.length ==arr2.length ) {
temp =new Array();
for(var i=0;i<arr1.length;i++){
temp.push(arr1[i]*arr2[i]);
}
resolve(temp);
} else {
reject(Error("Promise Rejected"));
}
});
}
//[1,2,5], [1,2,0],[2,2,2].[1,2,3]
var A=[1,2,5];
var B=[1,2,0];
var C=[2,2,2];
var D=[1,2,3];
arrMultiplication(A,B).then(function(result){
arrMultiplication(C,result).then(function(result){
arrMultiplication(D,result).then(function(result){
alert(result);
});
});
});
How can I do it simpler instead of calling promise many times
IF i have A B C D E F as arrays it will complex with this way.
how to make it easier.