Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 27cea5c

Browse files
committed
Use TS for example
1 parent db597fc commit 27cea5c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/mortgage.js examples/mortgage.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { Decimal128 } from "../src/decimal128.mjs";
2-
import { pow } from "./pow.js";
2+
import { pow } from "./pow.mjs";
33

44
const one = new Decimal128("1");
55
const paymentsPerYear = new Decimal128("12");
66

7-
function calculateMonthlyPayment(p, r, y) {
7+
function calculateMonthlyPayment(p: string, r: string, y: string): Decimal128 {
88
const principal = new Decimal128(p);
99
const annualInterestRate = new Decimal128(r);
1010
const years = new Decimal128(y);
1111
const monthlyInterestRate = annualInterestRate.divide(paymentsPerYear);
1212
const paymentCount = paymentsPerYear.multiply(years);
1313
const onePlusInterestRate = monthlyInterestRate.add(one);
14-
const ratePower = pow(onePlusInterestRate, paymentCount);
14+
const ratePower = pow(onePlusInterestRate, Number(paymentCount));
1515

1616
const x = principal.multiply(monthlyInterestRate);
1717

0 commit comments

Comments
 (0)