// e.g., If initial investment is -$500,000 and the cash flows are $200,000, $300,000, and $200,000, IRR is 18.82%.
// finance.IRR(initialInvestment, cashFlow1, cashFlow2, etc. );
finance.IRR(-500000, 200000, 300000, 200000);
=> 18.82
I’m stumped on why it would be the above signature instead of using a array like below:
originalInvestment (a number), and payoutList (an array of numbers)
I frankly have no clue how to turn the payoutList array into what I need for IRR. I can’t pass the array in. I can’t pass a string with the numbers separated by commas… the majority of array methods either return an array or a string. How can I get to this!!!:
Exception while invoking method 'Investments.getIRR' Error: IRR requires at least one positive value and one negative value
when I do this:
let originalInvestment = 5000;
let listOfAmounts = [1000, 2000, 3000];
const pos_to_neg = (num) => -Math.abs(num); // turn original investment into a negative number
let IRR = finance.IRR.apply(this, listOfAmounts.unshift(pos_to_neg(originalInvestment))); //push original investment to front of array and run financejs IRR
I get this:
Exception while invoking method 'Investments.getIRR' TypeError: Function.prototype.apply: Arguments list has wrong type