diff --git a/build/main.bundle.js b/build/main.bundle.js
index c71cc17..1c05a37 100644
--- a/build/main.bundle.js
+++ b/build/main.bundle.js
@@ -63,7 +63,7 @@
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 0);
+/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
@@ -73,6 +73,10 @@
"use strict";
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -87,13 +91,13 @@ var Mortgage = function () {
}
_createClass(Mortgage, [{
- key: 'monthlyPayment',
+ key: "monthlyPayment",
get: function get() {
var monthlyRate = this.rate / 100 / 12;
return this.principal * monthlyRate / (1 - Math.pow(1 / (1 + monthlyRate), this.years * 12));
}
}, {
- key: 'amortization',
+ key: "amortization",
get: function get() {
var monthlyPayment = this.monthlyPayment;
var monthlyRate = this.rate / 100 / 12;
@@ -118,18 +122,33 @@ var Mortgage = function () {
return Mortgage;
}();
+exports.default = Mortgage;
+
+/***/ }),
+/* 1 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+var _mortgage = __webpack_require__(0);
+
+var _mortgage2 = _interopRequireDefault(_mortgage);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
document.getElementById('calcBtn').addEventListener('click', function () {
- var principal = document.getElementById("principal").value;
- var years = document.getElementById("years").value;
- var rate = document.getElementById("rate").value;
- var mortgage = new Mortgage(principal, years, rate);
- document.getElementById("monthlyPayment").innerHTML = mortgage.monthlyPayment.toFixed(2);
- document.getElementById("monthlyRate").innerHTML = (rate / 12).toFixed(2);
- var html = "";
- mortgage.amortization.forEach(function (year, index) {
- return html += '\n
\n | ' + (index + 1) + ' | \n ' + Math.round(year.principalY) + ' | \n \n \n | \n ' + Math.round(year.interestY) + ' | \n ' + Math.round(year.balance) + ' | \n
\n ';
- });
- document.getElementById("amortization").innerHTML = html;
+ var principal = document.getElementById("principal").value;
+ var years = document.getElementById("years").value;
+ var rate = document.getElementById("rate").value;
+ var mortgage = new _mortgage2.default(principal, years, rate);
+ document.getElementById("monthlyPayment").innerHTML = mortgage.monthlyPayment.toFixed(2);
+ document.getElementById("monthlyRate").innerHTML = (rate / 12).toFixed(2);
+ var html = "";
+ mortgage.amortization.forEach(function (year, index) {
+ return html += '\n \n | ' + (index + 1) + ' | \n ' + Math.round(year.principalY) + ' | \n \n \n | \n ' + Math.round(year.interestY) + ' | \n ' + Math.round(year.balance) + ' | \n
\n ';
+ });
+ document.getElementById("amortization").innerHTML = html;
});
/***/ })
diff --git a/build/main.bundle.js.map b/build/main.bundle.js.map
index 6c331ba..d4dede3 100644
--- a/build/main.bundle.js.map
+++ b/build/main.bundle.js.map
@@ -1 +1 @@
-{"version":3,"sources":["webpack:///webpack/bootstrap 87a4a8b20aa950c121a1","webpack:///./js/main.js"],"names":["Mortgage","principal","years","rate","monthlyRate","Math","pow","monthlyPayment","balance","amortization","y","interestY","principalY","m","interestM","principalM","push","document","getElementById","addEventListener","value","mortgage","innerHTML","toFixed","html","forEach","year","index","round"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AA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C,gBAAnC,CAAoD,OAApD,EAA6D,YAAM;AAC/D,MAAIlB,YAAYgB,SAASC,cAAT,CAAwB,WAAxB,EAAqCE,KAArD;AACA,MAAIlB,QAAQe,SAASC,cAAT,CAAwB,OAAxB,EAAiCE,KAA7C;AACA,MAAIjB,OAAOc,SAASC,cAAT,CAAwB,MAAxB,EAAgCE,KAA3C;AACA,MAAIC,WAAW,IAAIrB,QAAJ,CAAaC,SAAb,EAAwBC,KAAxB,EAA+BC,IAA/B,CAAf;AACAc,WAASC,cAAT,CAAwB,gBAAxB,EAA0CI,SAA1C,GAAsDD,SAASd,cAAT,CAAwBgB,OAAxB,CAAgC,CAAhC,CAAtD;AACAN,WAASC,cAAT,CAAwB,aAAxB,EAAuCI,SAAvC,GAAmD,CAACnB,OAAO,EAAR,EAAYoB,OAAZ,CAAoB,CAApB,CAAnD;AACA,MAAIC,OAAO,EAAX;AACAH,WAASZ,YAAT,CAAsBgB,OAAtB,CAA8B,UAACC,IAAD,EAAOC,KAAP;AAAA,WAAiBH,8CAEjCG,QAAQ,CAFyB,iDAGhBtB,KAAKuB,KAAL,CAAWF,KAAKd,UAAhB,CAHgB,0KAOZc,KAAKd,UAPO,sBAOoBc,KAAKd,UAPzB,4HAUZc,KAAKf,SAVO,sBAUmBe,KAAKf,SAVxB,yHAcXN,KAAKuB,KAAL,CAAWF,KAAKf,SAAhB,CAdW,gDAehBN,KAAKuB,KAAL,CAAWF,KAAKlB,OAAhB,CAfgB,+BAAjB;AAAA,GAA9B;AAkBAS,WAASC,cAAT,CAAwB,cAAxB,EAAwCI,SAAxC,GAAoDE,IAApD;AAEH,CA5BD,E","file":"main.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 87a4a8b20aa950c121a1","class Mortgage {\r\n constructor(principal, years, rate) {\r\n this.principal = principal;\r\n this.years = years;\r\n this.rate = rate;\r\n }\r\n\r\n get monthlyPayment() {\r\n let monthlyRate = this.rate / 100 / 12;\r\n return this.principal * monthlyRate / (1 - (Math.pow(1/(1 + monthlyRate),\r\n this.years * 12)));\r\n }\r\n\r\n get amortization() {\r\n let monthlyPayment = this.monthlyPayment;\r\n let monthlyRate = this.rate / 100 / 12;\r\n let balance = this.principal;\r\n let amortization = [];\r\n for (let y=0; y {\r\n let principal = document.getElementById(\"principal\").value;\r\n let years = document.getElementById(\"years\").value;\r\n let rate = document.getElementById(\"rate\").value;\r\n let mortgage = new Mortgage(principal, years, rate);\r\n document.getElementById(\"monthlyPayment\").innerHTML = mortgage.monthlyPayment.toFixed(2);\r\n document.getElementById(\"monthlyRate\").innerHTML = (rate / 12).toFixed(2);\r\n let html = \"\";\r\n mortgage.amortization.forEach((year, index) => html += `\r\n \r\n | ${index + 1} | \r\n ${Math.round(year.principalY)} | \r\n \r\n \r\n | \r\n ${Math.round(year.interestY)} | \r\n ${Math.round(year.balance)} | \r\n
\r\n `);\r\n document.getElementById(\"amortization\").innerHTML = html;\r\n\r\n});\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/main.js"],"sourceRoot":""}
\ No newline at end of file
+{"version":3,"sources":["webpack:///webpack/bootstrap 9edd4fe9f5aeed5ea03c","webpack:///./js/mortgage2.js","webpack:///./js/main.js"],"names":["Mortgage","principal","years","rate","monthlyRate","Math","pow","monthlyPayment","balance","amortization","y","interestY","principalY","m","interestM","principalM","push","document","getElementById","addEventListener","value","mortgage","innerHTML","toFixed","html","forEach","year","index","round"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;IChEqBA,Q;AACnB,oBAAYC,SAAZ,EAAuBC,KAAvB,EAA8BC,IAA9B,EAAoC;AAAA;;AAClC,SAAKF,SAAL,GAAiB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AAgCE,KAA3C;AACA,QAAIC,WAAW,uBAAapB,SAAb,EAAwBC,KAAxB,EAA+BC,IAA/B,CAAf;AACAc,aAASC,cAAT,CAAwB,gBAAxB,EAA0CI,SAA1C,GAAsDD,SAASd,cAAT,CAAwBgB,OAAxB,CAAgC,CAAhC,CAAtD;AACAN,aAASC,cAAT,CAAwB,aAAxB,EAAuCI,SAAvC,GAAmD,CAACnB,OAAO,EAAR,EAAYoB,OAAZ,CAAoB,CAApB,CAAnD;AACA,QAAIC,OAAO,EAAX;AACAH,aAASZ,YAAT,CAAsBgB,OAAtB,CAA8B,UAACC,IAAD,EAAOC,KAAP;AAAA,eAAiBH,8CAEjCG,QAAQ,CAFyB,iDAGhBtB,KAAKuB,KAAL,CAAWF,KAAKd,UAAhB,CAHgB,0KAOZc,KAAKd,UAPO,sBAOoBc,KAAKd,UAPzB,4HAUZc,KAAKf,SAVO,sBAUmBe,KAAKf,SAVxB,yHAcXN,KAAKuB,KAAL,CAAWF,KAAKf,SAAhB,CAdW,gDAehBN,KAAKuB,KAAL,CAAWF,KAAKlB,OAAhB,CAfgB,+BAAjB;AAAA,KAA9B;AAkBAS,aAASC,cAAT,CAAwB,cAAxB,EAAwCI,SAAxC,GAAoDE,IAApD;AAEH,CA5BD,E","file":"main.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 9edd4fe9f5aeed5ea03c","export default class Mortgage {\r\n constructor(principal, years, rate) {\r\n this.principal = principal;\r\n this.years = years;\r\n this.rate = rate;\r\n }\r\n\r\n get monthlyPayment() {\r\n let monthlyRate = this.rate / 100 / 12;\r\n return this.principal * monthlyRate / (1 - (Math.pow(1/(1 + monthlyRate),\r\n this.years * 12)));\r\n }\r\n\r\n get amortization() {\r\n let monthlyPayment = this.monthlyPayment;\r\n let monthlyRate = this.rate / 100 / 12;\r\n let balance = this.principal;\r\n let amortization = [];\r\n for (let y=0; y {\r\n let principal = document.getElementById(\"principal\").value;\r\n let years = document.getElementById(\"years\").value;\r\n let rate = document.getElementById(\"rate\").value;\r\n let mortgage = new Mortgage(principal, years, rate);\r\n document.getElementById(\"monthlyPayment\").innerHTML = mortgage.monthlyPayment.toFixed(2);\r\n document.getElementById(\"monthlyRate\").innerHTML = (rate / 12).toFixed(2);\r\n let html = \"\";\r\n mortgage.amortization.forEach((year, index) => html += `\r\n \r\n | ${index + 1} | \r\n ${Math.round(year.principalY)} | \r\n \r\n \r\n | \r\n ${Math.round(year.interestY)} | \r\n ${Math.round(year.balance)} | \r\n
\r\n `);\r\n document.getElementById(\"amortization\").innerHTML = html;\r\n\r\n});\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/main.js"],"sourceRoot":""}
\ No newline at end of file
diff --git a/js/main.js b/js/main.js
index 0a6bfb7..132fc65 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1,38 +1,4 @@
-class Mortgage {
- constructor(principal, years, rate) {
- this.principal = principal;
- this.years = years;
- this.rate = rate;
- }
-
- get monthlyPayment() {
- let monthlyRate = this.rate / 100 / 12;
- return this.principal * monthlyRate / (1 - (Math.pow(1/(1 + monthlyRate),
- this.years * 12)));
- }
-
- get amortization() {
- let monthlyPayment = this.monthlyPayment;
- let monthlyRate = this.rate / 100 / 12;
- let balance = this.principal;
- let amortization = [];
- for (let y=0; y {
let principal = document.getElementById("principal").value;
diff --git a/js/mortgage2.js b/js/mortgage2.js
new file mode 100644
index 0000000..7a3eef9
--- /dev/null
+++ b/js/mortgage2.js
@@ -0,0 +1,33 @@
+export default class Mortgage {
+ constructor(principal, years, rate) {
+ this.principal = principal;
+ this.years = years;
+ this.rate = rate;
+ }
+
+ get monthlyPayment() {
+ let monthlyRate = this.rate / 100 / 12;
+ return this.principal * monthlyRate / (1 - (Math.pow(1/(1 + monthlyRate),
+ this.years * 12)));
+ }
+
+ get amortization() {
+ let monthlyPayment = this.monthlyPayment;
+ let monthlyRate = this.rate / 100 / 12;
+ let balance = this.principal;
+ let amortization = [];
+ for (let y=0; y