title: Why am I getting NaN from this XIRR function?
body: <p>This one is driving me up the wall.</p>
  
  <p>UPDATE: Assembled in a jsfiddle that yields NaN: <a href="https://jsfiddle.net/eqcww2y7/6/" rel="nofollow noreferrer">https://jsfiddle.net/eqcww2y7/6/</a></p>
  
  <p>I'm using this XIRR function: <a href="https://gist.github.com/ghalimi/4669712" rel="nofollow noreferrer">https://gist.github.com/ghalimi/4669712</a></p>
  
  <p>And into that function, I'm sending a simple pair of arrays - 4 dates, 4 cashflow values. </p>
  
  <pre><code>var dates = [
    "2016-01-01",
    "2016-02-01",
    "2016-03-01",
    "2016-04-01",
  ];
  
  var values = [
    -1000000,
    0,
    0,
    750000
  ];
  
  console.log('dates', dates);
  console.log('values', values);
  console.log(XIRR(values, dates, 0.1));
  </code></pre>
  
  <p>The function has a dependency on momentjs, which is not causing any issues - <code>console.log()</code> inside the function shows the dates are being parsed correctly.</p>
  
  <p>That snippet above returns NaN, when it should return -0.68. If I run those exact same values through Excel:</p>
  
  <p><a href="https://i.stack.imgur.com/GMzh3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GMzh3.png" alt="Testing XIRR in Excel"></a></p>
  
  <p>Can anyone spot the issue? Is it with the function, am I sending the wrong values in?</p>