diff --git a/index.html b/index.html
index b458c1ff..0da5789e 100644
--- a/index.html
+++ b/index.html
@@ -1,13 +1,76 @@
-
- JavaScript Foundations
-
-
-
-
- Open up the console to check your work!
-
-
+
+
+
+
+
+
+
+
+
+
JavaScript Foundations Mortgage Calculator
+
+
This is a project. Please refer to you bank for actual
+
+
-
+
\ No newline at end of file
diff --git a/index.js b/index.js
index 667af155..2aa342d0 100644
--- a/index.js
+++ b/index.js
@@ -103,3 +103,41 @@ For example, variableInterestRate(200000, 0.04, 30) should console.log:
/* 🏡 Refactor your `variableInterestRate()` function to accept an array of interest rates (make sure to copy and paste as to not lose your work!) */
+
+
+
+
+
+
+
+
+function checkForZero(field) {
+ if (field.value == 0 || field.value.length == 0) {
+ alert ("This field can't be 0!");
+ field.focus(); }
+ else
+ calculatePayment(field.form);
+}
+
+function cmdCalc_Click(form) {
+ if (form.price.value == 0 || form.price.value.length == 0) {
+ alert ("The Price field can't be 0!");
+ form.price.focus(); }
+ else if (form.ir.value == 0 || form.ir.value.length == 0) {
+ alert ("The Interest Rate field can't be 0!");
+ form.ir.focus(); }
+ else if (form.term.value == 0 || form.term.value.length == 0) {
+ alert ("The Term field can't be 0!");
+ form.term.focus(); }
+ else
+ calculatePayment(form);
+}
+
+function calculatePayment(form) {
+ princ = form.price.value - form.dp.value;
+ intRate = (form.ir.value/100) / 12;
+ months = form.term.value * 12;
+ form.pmt.value = Math.floor((princ*intRate)/(1-Math.pow(1+intRate,(-1*months)))*100)/100;
+ form.principle.value = princ;
+form.payments.value = months;
+}
\ No newline at end of file