Skip to content
Advertisement

Calculating investment values with javascript

I am currently learning javascript. I have created a calculator to find invesment future value. It is giving me an incorrect value when it displays the future value. I have checked the formula several times but it still gives me an error. Also, I have set alerts to appear if the interest is less than 0 or greater than 20 but nothing is showing. How would i be able to properly display the correct future value and alerts when necessary? Example

Javascript

JavaScript

Advertisement

Answer

Using .value is incorrect, its javascript, while this is jquery, try adding a # in front and use .val() instead.

Its similar to this:

jquery function val() is not equivalent to “$(this).value=”?

EDIT

He’s not using jquery, ignore this.

Advertisement