Forum Discussion

MichaelCurtis's avatar
MichaelCurtis
Qrew Cadet
7 years ago

Math.pow()

I am trying to recreate a loan calculator I had originally created in javascript. The problem is I cannot find a workaround for the Math.pow() method. I would like to do this without IOL and stick to QuickBase formulas 

const principal = parseFloat(amount.value)
const calculatedInterest = parseFloat(interest.value) / 100 / 12
const calculatedPayments = parseFloat(years.value) * 12

// Compute monthly payment
const x = Math.pow(1 + calculatedInterest, calculatedPayments)
const monthly = (principal * x * calculatedInterest) / (x - 1)

if (isFinite(monthly)) {
monthlyPayment.value = monthly.toFixed(2)
totalPayment.value = (monthly * calculatedPayments).toFixed(2)
totalInterest.value = ((monthly * calculatedPayments) - principal).toFixed(2)

//Show Results
document.getElementById('results').style.display = 'block'

//Hide Spinner
document.getElementById('loading').style.display = 'none'
} else {
showError('Please Check Your Numbers')

}