Creating a custom JavaScript calculation based on complex Excel formula
I have a complex Excel formula that needs to be converted to JavaScript to create a custom calculation on the "Pepare a Form" tool. I have no experience with JS.
I am trying to calculate how much I need to save each month based on my different savings goals. Note, that the field amounts will be variable, and do not want to have to write a code for each box of the monthly contribution required.
Example amounts are:
| Goal amount (J17) | $10,000 |
| Current balance (J18) | $1,000 |
| Needed in x years (J19) | 1 |
| Needed in x months (J20) | 6 |
| Expected annual interest/return (J21) | 4% |
The excel formula to find out how I need to save each month is:
=IF(J21=0,(J17-J18)/((J19*12)+J20),((J17-(J18*(1+J21/12)^(J20 +(J19*12))))*(J21/12))/((1+J21/12)^(J20+(J19*12))-1))
It the formula needs to have the output (based on the example amounts provided) of 482.65.
Then should be rounded to the next nearest whole number. The excel formula for that is: =ROUND(J24,0) with the output of 483. Note that J24=482.65.
Thank you for your help!!
