How to do asynchronous operation using for loop and promise without arrow function and aysnc/await I have array, iterate through it in synchronously. during async task as in below code, i value to be executed synchronously(example: say when i value is 2, wait until async task is finished, once async response comes move to next value of i, if validations of if conditions fails)
array = [{a:1,b:0,c:3,d:3},{a:1,b:0,c:0,d:5},{a:1,b:2,c:3,d:2},{a:1,b:2,c:3,d:error}]
for (var i =0 ;i<=array.length;i--){
if (array[i].d == 'error'){
console.log("D's Value is Error");
return false;
}
if(array[i].a == 0){
console.log("A is Zero");
return false;
}
if (array[i].b == 0 && array[i].c == 0){
//do async task using promise based on response return the value back
Promise.then(function(response){
if (!response){
return false
} else {
return true;
}
}).catch(function(err){
return false;
});
}
}