Write a function named investment
that takes three number parameters, initial
, percent
, and months
, representing the initial amount of an investment, the interest rate percentage of that investment, and the length of the investment in months. Using the following compound interest formula, your function should calculate the profit of the investment for the given values:
PV * (1 + r)n = FV
Also report the overall "quality" of the investment as from the table below:
Profit |
Category |
0 - 10% |
weak |
10 - 50% |
medium |
over 50% |
strong |
Below is example output when calling investment(100.00, 0.03, 5)
, representing the investment of $100 with a 3% interest rate for 5 months:
Final amount = $115.93
Profit = $15.93 (16%)
medium
Use the console.log()
function to print each line of output and n.toFixed(2)
to get a string of a number n
to the precision of two decimal points. For example, if n
is 1.2345, n.toFixed(2)
would return "1.23"
.
Percentage values for an investment's profit should be rounded to the nearest whole integer.