【发布时间】:2019-08-31 09:28:57
【问题描述】:
我有一个带有一系列信用报告历史记录的贷款对象,每个信用报告都有一系列信用评分。我想获取上次信用报告的最后信用评分
let creditReportHistory = loanInfo.creditReportHistory;
let lastReport = creditReportHistory ? _.last(creditReportHistory) : null;
let lastScore = lastReport ? _.last(lastReport.creditScores) : null;
return (
loanInfo.fico !== null && // has a score
_.isArray(creditReportHistory) && // history is an array
creditReportHistory.length > 0 && // at least one credit report
lastScore === null // last report has a last score that is null
);
上面的代码基本上需要知道最后一个report的最后一个score是否为null。其他条件不依赖于 lodash "last()" 调用。
【问题讨论】: