I'm new to javascript and Promises, Here is the array:
(我是javascript和Promises的新手,这里是数组:)
resultSet: [
{loanID : "LN111", branch:"ABC", status:"APPROVED"},
{loanID : "LN222", branch:"ABC", status:"REJECTED"},
{loanID : "LN333", branch:"ABC", status:"APPROVED"}
]
I have two functions each take input argument as an object with status value either 'APPROVED' and 'REJECTED' and it's loanID
(我有两个函数,每个函数都将输入参数作为状态值为“ APPROVED”和“ REJECTED”的对象,并且它的借贷标识为)
function A : return functionApprove(resultSet) --> this one takes object which has status = 'APPROVED'
function B : return functionReject(resultSet) --> this one takes object which has status = 'REJECTED'
How do sequentially execute this two functions by using Reduce by looping over each element in resultSet.
(如何通过在resultSet中的每个元素上循环使用Reduce来依次执行这两个函数。)
So far my try is below:
(到目前为止,我的尝试如下:)
function ProcessRecords(){
for (i = 0; i < resultSet.length; i++){
if (resultSet[i].status = "APPROVED"){
return functionApprove(resultSet[i].loanID)
.then (function(response){"call another function do some updates with the response"});
else {
return functionReject(resultSet[i].loanID)
.then (function(response){"call another function do some updates with the response"});
};
ask by Mar1009 translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…