FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Easy

Mortgage Calculator

20 mins

Build a simple mortgage calculator widget that allows users to calculate monthly mortgage payments.

Requirements:

  1. Inputs:
    • Loan amount ($)
    • Annual interest rate (%)
    • Loan term (in years)
  2. Outputs:
    • Monthly mortgage payment
    • Total payment amount
    • Total interest paid
  3. If a non-numeric or invalid input is provided, display an error message.
  4. Round all result amounts to 2 decimal places.
  5. Use the formula:

M = P(i(1+i)^n) / ((1+i)^n - 1)

Where:

  • M = Monthly mortgage payment
  • P = Loan amount
  • i = Monthly interest rate (APR / 12)
  • n = Total number of payments (years × 12)

Code Editor

React Component

00:00
Loading...

Live Preview

See your React component