Skip to content Skip to sidebar Skip to footer

Function Sum Not Working Properly Javascript

When i add two fields, the code doesn't sum it but instead, it adds both what I inputted, heres my code function calculate_loan() { var amountBorrowed = document.form.amountBorro

Solution 1:

You should parse the values as numbers

var amountBorrowed = Number(document.form.amountBorrowed.value);
var interest = Number(document.form.interest.value) / 100;
var payments = Number(document.form.durationOfPayment.value);
var monthInterest = Number(document.form.interestPerMonth.value);
var totalInt = Number(document.form.totalinterest.value);

Post a Comment for "Function Sum Not Working Properly Javascript"