Dollar cost average / investment calculator
https://github.com/RyanHazlewood0/crypto-app/pull/49 https://www.loom.com/share/a03c20956dbe41a999e5a8538aaf267b been struggling pretty bad with this component, really knocked some confidence out of me π
π¬ When I enter the dates and other inputs and click calculate, it does work (shows the correct amount spent and total investment value). But if I then change the finish date and click calculate again, it shows a very low number (or sometimes 0) for the total value. So it works the first time but not after that. I think the problem lies in this piece of code which is inside the getTotalVal function: const purchaseDateObjects = priceData.filter((priceObj) => { return dates.some( (date) => new Date(date).toISOString().split("T")[0] === priceObj.date.toISOString().split("T")[0] ); }); after changing the finish date, purchaseDateObjects ends up having only a small number of dates in it, missing a lot of them. Or sometimes its just empty, resulting in totalCoinHolding = either an incorrect / low figure or 0. If I just change the start date there are no problems, just happens with the finish date. Appreciate any input thanks.