function IRR(cashFlows, estimatedResult) { var result = "isNAN"; if (cashFlows != null && cashFlows.length > 0) { // check if business startup costs is not zero: if (cashFlows[0] != 0) { var noOfCashFlows = cashFlows.length; var sumCashFlows = 0; // check if at least 1 positive and 1 negative cash flow exists: var noOfNegativeCashFlows = 0; var noOfPositiveCashFlows = 0; for (var i = 0; i < noOfCashFlows; i++) { sumCashFlows += cashFlows[i]; if (cashFlows[i] > 0) { noOfPositiveCashFlows++; } else { if (cashFlows[i] < 0) { noOfNegativeCashFlows++; } } } // at least 1 negative and 1 positive cash flow available? if (noOfNegativeCashFlows > 0 && noOfPositiveCashFlows
JavaScript IRR 算法
最新推荐文章于 2024-05-14 09:57:01 发布