I have a code structure like this:
function f1() {
return f2().then(function(res2) {
var arr = res2;
var a = "default";
arr.forEach(function(element) {
if (element.condition) {
...
}
else {
f3().then(function(res3) {
a = res3;
});
}
};
return [arr, a];
});
};
f1().then(function(result) {
console.log(result[0]);
console.log(result[1]);
});
result[0] (array) has actual value of array, however, result[1] (a) is "default". How should I modify the code above to get the actual value of 'a'?