我有if语句的代码(如下)。有可能重构这段代码吗?因为在这个方法中是丑陋的if语句:(
getOverallAmount(estimate) {
const {installments} = estimate;
const {vipValue} = estimate;
if (installments !== 1) {
const oneInstallment = vipValue / installments;
const allWithOneInst = vipValue - (oneInstallment * installments) + 1;
return oneInstallment + allWithOneInst;
}
return vipValue;
}
1条答案
按热度按时间zwghvu4y1#
使用三元运算符而不是
if
声明: