# Amortization Calculator Formula With JS

Hello Everyone Thought to share this with you’ll that I posted for another user’s question!

This script calculates the Monthly Payment with amount , term and interest rate.

Made a video : Loom | Free Screen & Video Recording Software

And the JS :

``````var Rate = "5" / 100;
var Term = "48";
var Price = "67890";
var value = Price * (Rate/12) * (Math.pow((1 + (Rate/12)), Term))/ ((Math.pow((1 + (Rate/12)), Term)) - 1);
var value = Math.round(100*value)/100;
return value;
``````

In here change the rate inside double quotes with the drop down’s rate and for the term, term drop-down value and for the price add the input that user type the amount.

Instructions to download components from Pragmaflow website : PragmaFlow's Adalo Marketplace Reopened - YouTube

Pragmaflow website : PragmaFlow Adalo Toolkit

The component you need : And also you can hide the inputs and the JS component!

Hope this helps!

Thank you

1 Like

Hi every one, lots of thanks to @dilon_perera for taking time to do this, I recently implemented this to my PWA and it works perfectly, @dilon_perera how can I have user enter loan down payment, instead of the loan amount and second how do I format the result.
Here the link to the app.

Thanks

1 Like

Can you give me an example?

In your text component select custom formula from the options when you click the magic text and then add the input inside the custom formula and then you can format it to the currency. Or I can add that to the JS code if you tell me which format you need!

And also nice app Peter! Good luck with your app!

Hi @dilon_perera ,
Thank you for your help. When you click under the car photo you will link to listing detail where there is “buy this” button, click it and will take you to how to pay. So here I need the price of a car to be default loan amount so user just enter what down payment they going to put down so the loan amount is car price minus downpayment the user entered.

The format for results I can’t follow how to do it, could you add it to the formula please,
Thanks @dilon_perera
Appreciated.

Is it possible to give an example calculation with the results?

I have shown this on that video! What’s the format you need?

The format is the number punctuated by comma without the decimal places like this,
123,345,678

1 Like

Something like this? : Loom | Free Screen & Video Recording Software ( I’m sorry that I said Paul to you and you are Peter  )

Or round that number?

Thanks for the video! Nicely explained!

Need to confirm the result! Based on your values does your result would be this?  Thats ok, no problem.
So let me put it this way.

The car price is 10,000
Buyer has to deposit 2,000 so he has to enter 2,000 into downpayment input
So bank gives buyer a 8,000 loan which become the loan amount

So the formula should take 8,000 as the loan amount which comes from deducting 2,000 from 10,000 . So the formula take has the price of a car, wait user to enter amount he wants to put down and the formular take that number and deduct from the car price before it calculate monthly payment for loan of 8,000. I hope that help

1 Like

Correct?

``````var Rate = "rate from dropdown" / 100;
var Term = "term from dropdown";
var Price = "car price"-"downpayment input";
var value = Price * (Rate/12) * (Math.pow((1 + (Rate/12)), Term))/ ((Math.pow((1 + (Rate/12)), Term)) - 1);
var value = Math.round(100*value)/100;
var formatvalue = Math.trunc(value).toLocaleString();
return formatvalue;
``````

Hi @dilon_perera,
I just implemented the new formula and it works exactly the way I wanted.
thank you so much.
Check it out and share if you want
www.motokaa.app

1 Like

Awesome @peterkilaba!

Wishing you the best of luck with your app!