Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions code/module-03/m03-end/build/module03.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function intOnlyLoan(loanTerms) {
// Calculates the monthly payment of an interest only loan
let intr = loanTerms.interestRate / 1200; // Calculates the Monthly Interest Rate of the loan
let pmt;
pmt = loanTerms.principle * intr;
pmt = loanTerms.principal * intr;
return 'The interest only loan payment is ' + pmt.toFixed(2);
}
/* TODO: Update the convLoan function, this time replacing the three parameters with an
Expand All @@ -22,10 +22,10 @@ function convLoan(loanTerms) {
// Calculates the monthly payment of a conventional loan
let intr = loanTerms.interestRate / 1200; // Calculates the Monthly Interest Rate of the loan
let pmt;
pmt = loanTerms.principle * intr / (1 - (Math.pow(1 / (1 + intr), loanTerms.numMonths)));
pmt = loanTerms.principal * intr / (1 - (Math.pow(1 / (1 + intr), loanTerms.numMonths)));
return 'The conventional loan payment is ' + pmt.toFixed(2);
}
let loan1 = intOnlyLoan({ principle: 30000, interestRate: 5 });
let loan2 = convLoan({ principle: 30000, interestRate: 5, numMonths: 180 });
let loan1 = intOnlyLoan({ principal: 30000, interestRate: 5 });
let loan2 = convLoan({ principal: 30000, interestRate: 5, numMonths: 180 });
console.log(loan1); //* Returns "The interest only loan payment is 125.00"
console.log(loan2); //* Returns "The conventional loan payment is 237.24"
10 changes: 5 additions & 5 deletions code/module-03/m03-end/module03.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
TODO: Declare the Loan interface. */

interface Loan {
principle: number,
principal: number,
interestRate: number //* Interest rate percentage (eg. 14 is 14%)
}

Expand All @@ -21,7 +21,7 @@ function calculateInterestOnlyLoanPayment(loanTerms: Loan): string {
// Calculates the monthly payment of an interest only loan
let interest: number = loanTerms.interestRate / 1200; // Calculates the Monthly Interest Rate of the loan
let payment: number;
payment = loanTerms.principle * interest;
payment = loanTerms.principal * interest;
return 'The interest only loan payment is ' + payment.toFixed(2);
}

Expand All @@ -31,12 +31,12 @@ function calculateConventionalLoanPayment(loanTerms: ConventionalLoan): string {
// Calculates the monthly payment of a conventional loan
let interest: number = loanTerms.interestRate / 1200; // Calculates the Monthly Interest Rate of the loan
let payment: number;
payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
payment = loanTerms.principal * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
return 'The conventional loan payment is ' + payment.toFixed(2);
}

let interestOnlyPayment = calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5});
let conventionalPayment = calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180});
let interestOnlyPayment = calculateInterestOnlyLoanPayment({principal: 30000, interestRate: 5});
let conventionalPayment = calculateConventionalLoanPayment({principal: 30000, interestRate: 5, months: 180});

console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00"
console.log(conventionalPayment); //* Returns "The conventional loan payment is 237.24"
8 changes: 4 additions & 4 deletions code/module-03/m03-start/module03.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

/* TODO: Update the calculateInterestOnlyLoanPayment function. */

function calculateInterestOnlyLoanPayment(principle, interestRate) {
function calculateInterestOnlyLoanPayment(principal, interestRate) {
// Calculates the monthly payment of an interest only loan
let interest = interestRate / 1200; // Calculates the Monthly Interest Rate of the loan
let payment;
payment = principle * interest;
payment = principal * interest;
return 'The interest only loan payment is ' + payment.toFixed(2);
}

/* TODO: Update the calculateConventionalLoanPayment function. */

function calculateConventionalLoanPayment(principle, interestRate, months) {
function calculateConventionalLoanPayment(principal, interestRate, months) {
// Calculates the monthly payment of a conventional loan
let interest = interestRate / 1200; // Calculates the Monthly Interest Rate of the loan
let payment;
payment = principle * interest / (1 - (Math.pow(1 / (1 + interest), months)));
payment = principal * interest / (1 - (Math.pow(1 / (1 + interest), months)));
return 'The conventional loan payment is ' + payment.toFixed(2);
}

Expand Down
4 changes: 2 additions & 2 deletions code/module-04/m04-end/build/module04.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ console.log(myArray2);
TODO: Convert the LoanCalc function to TypeScript with strongly typed parameters, variables,
and return types. Make the numMonths parameter optional but assign it a default value of 12
months if omitted. */
function LoanCalc(principle, interestRate, numMonths = 12) {
function LoanCalc(principal, interestRate, numMonths = 12) {
let intr = interestRate / 1200; // Calculates the monthly interest rate
let pmt;
Number;
pmt = principle * intr / (1 - (Math.pow(1 / (1 + intr), numMonths)));
pmt = principal * intr / (1 - (Math.pow(1 / (1 + intr), numMonths)));
return pmt.toFixed(2);
}
let myLoan = LoanCalc(1000, 5);
Expand Down
4 changes: 2 additions & 2 deletions code/module-04/m04-end/module04.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ console.log(myArray2);
/* EXERCISE 2
TODO: Update the LoanCalculator function. */

function loanCalculator (principle: number, interestRate: number, months = 12): string {
function loanCalculator (principal: number, interestRate: number, months = 12): string {
let interest: number = interestRate / 1200; // Calculates the monthly interest rate
let payment: number;
payment = principle * interest / (1 - (Math.pow(1/(1 + interest), months)));
payment = principal * interest / (1 - (Math.pow(1/(1 + interest), months)));
return payment.toFixed(2);
}

Expand Down
4 changes: 2 additions & 2 deletions code/module-04/m04-start/module04.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ let myArray2 = buildArray(8, 'descending');
/* EXERCISE 2
TODO: Update the LoanCalculator function. */

function loanCalculator (principle, interestRate, months) {
function loanCalculator (principal, interestRate, months) {
let interest = interestRate / 1200; // Calculates the monthly interest rate
let payment;
payment = principle * interest / (1 - (Math.pow(1/(1 + interest), months)));
payment = principal * interest / (1 - (Math.pow(1/(1 + interest), months)));
return payment.toFixed(2);
}
4 changes: 2 additions & 2 deletions code/module-07/m07-end/module07_loan-programs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ exports.calculateConventionalLoanPayment = exports.calculateInterestOnlyLoanPaym
/* TODO Update the calculateInterestOnlyLoanPayment function. */
function calculateInterestOnlyLoanPayment(loanTerms) {
var payment;
payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate);
payment = loanTerms.principal * calculateInterestRate(loanTerms.interestRate);
return 'The interest only loan payment is ' + payment.toFixed(2);
}
exports.calculateInterestOnlyLoanPayment = calculateInterestOnlyLoanPayment;
/* TODO Update the calculateConventionalLoanPayment function. */
function calculateConventionalLoanPayment(loanTerms) {
var interest = calculateInterestRate(loanTerms.interestRate);
var payment;
payment = loanTerms.principle * interest / (1 - (Math.pow(1 / (1 + interest), loanTerms.months)));
payment = loanTerms.principal * interest / (1 - (Math.pow(1 / (1 + interest), loanTerms.months)));
return 'The conventional loan payment is ' + payment.toFixed(2);
}
exports.calculateConventionalLoanPayment = calculateConventionalLoanPayment;
Expand Down
6 changes: 3 additions & 3 deletions code/module-07/m07-end/module07_loan-programs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import * as Loans from './module07_loans.js';
/* TODO Update the calculateInterestOnlyLoanPayment function. */
export function calculateInterestOnlyLoanPayment(loanTerms: Loans.Loan): string {
let payment: number;
payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate);
payment = loanTerms.principal * calculateInterestRate(loanTerms.interestRate);
return 'The interest only loan payment is ' + payment.toFixed(2);
}
/* TODO Update the calculateConventionalLoanPayment function. */
export function calculateConventionalLoanPayment(loanTerms: Loans.ConventionalLoan): string {
let interest: number = calculateInterestRate(loanTerms.interestRate);
let payment: number;
payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
payment = loanTerms.principal * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
return 'The conventional loan payment is ' + payment.toFixed(2);
}
function calculateInterestRate (interestRate: number): number {
let interest: number = interestRate / 1200;
return interest
}
}
4 changes: 2 additions & 2 deletions code/module-07/m07-end/module07_loans.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* TODO Update the interface declarations. */
export interface Loan {
principle: number,
principal: number,
interestRate: number //* Interest rate percentage (eg. 14 is 14%)
}
export interface ConventionalLoan extends Loan {
months: number //* Total number of months
}
}
4 changes: 2 additions & 2 deletions code/module-07/m07-end/module07_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports.__esModule = true;
/* TODO Add the import statement. */
var LoanPrograms = require("./module07_loan-programs.js");
/* TODO Update the function calls. */
var interestOnlyPayment = LoanPrograms.calculateInterestOnlyLoanPayment({ principle: 30000, interestRate: 5 });
var conventionalLoanPayment = LoanPrograms.calculateConventionalLoanPayment({ principle: 30000, interestRate: 5, months: 180 });
var interestOnlyPayment = LoanPrograms.calculateInterestOnlyLoanPayment({ principal: 30000, interestRate: 5 });
var conventionalLoanPayment = LoanPrograms.calculateConventionalLoanPayment({ principal: 30000, interestRate: 5, months: 180 });
console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00"
console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24"
4 changes: 2 additions & 2 deletions code/module-07/m07-end/module07_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as LoanPrograms from './module07_loan-programs.js';

/* TODO Update the function calls. */
let interestOnlyPayment = LoanPrograms.calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5});
let conventionalLoanPayment = LoanPrograms.calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180});
let interestOnlyPayment = LoanPrograms.calculateInterestOnlyLoanPayment({principal: 30000, interestRate: 5});
let conventionalLoanPayment = LoanPrograms.calculateConventionalLoanPayment({principal: 30000, interestRate: 5, months: 180});
console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00"
console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24"
6 changes: 3 additions & 3 deletions code/module-07/m07-start/module07_loan-programs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
/* TODO Update the calculateInterestOnlyLoanPayment function. */
function calculateInterestOnlyLoanPayment(loanTerms: Loan): string {
let payment: number;
payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate);
payment = loanTerms.principal * calculateInterestRate(loanTerms.interestRate);
return 'The interest only loan payment is ' + payment.toFixed(2);
}
/* TODO Update the calculateConventionalLoanPayment function. */
function calculateConventionalLoanPayment(loanTerms: ConventionalLoan): string {
let interest: number = calculateInterestRate(loanTerms.interestRate);
let payment: number;
payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
payment = loanTerms.principal * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
return 'The conventional loan payment is ' + payment.toFixed(2);
}
function calculateInterestRate (interestRate: number): number {
let interest: number = interestRate / 1200;
return interest
}
}
4 changes: 2 additions & 2 deletions code/module-07/m07-start/module07_loans.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* TODO Update the interface declarations. */
interface Loan {
principle: number,
principal: number,
interestRate: number //* Interest rate percentage (eg. 14 is 14%)
}
interface ConventionalLoan extends Loan {
months: number //* Total number of months
}
}
4 changes: 2 additions & 2 deletions code/module-07/m07-start/module07_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* TODO Add the import statement. */

/* TODO Update the function calls. */
let interestOnlyPayment = calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5});
let conventionalLoanPayment = calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180});
let interestOnlyPayment = calculateInterestOnlyLoanPayment({principal: 30000, interestRate: 5});
let conventionalLoanPayment = calculateConventionalLoanPayment({principal: 30000, interestRate: 5, months: 180});
console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00"
console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24"
4 changes: 2 additions & 2 deletions code/module-08/m08-end/module08_loan-programs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ namespace LoanPrograms {
// Calculates the monthly payment of an interest only loan
export function calculateInterestOnlyLoanPayment(loanTerms: Loans.Loan): string {
let payment: number;
payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate);
payment = loanTerms.principal * calculateInterestRate(loanTerms.interestRate);
return 'The interest only loan payment is ' + payment.toFixed(2);
}
// Calculates the monthly payment of a conventional loan
export function calculateConventionalLoanPayment(loanTerms: Loans.ConventionalLoan): string {
let interest: number = calculateInterestRate(loanTerms.interestRate);
let payment: number;
payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
payment = loanTerms.principal * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
return 'The conventional loan payment is ' + payment.toFixed(2);
}
function calculateInterestRate (interestRate: number): number {
Expand Down
2 changes: 1 addition & 1 deletion code/module-08/m08-end/module08_loans.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

namespace Loans {
export interface Loan {
principle: number,
principal: number,
interestRate: number //* Interest rate percentage (eg. 14 is 14%)
}
export interface ConventionalLoan extends Loan {
Expand Down
4 changes: 2 additions & 2 deletions code/module-08/m08-end/module08_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// <reference path="module08_loan-programs.ts" />

/* TODO Update the function calls. */
let interestOnlyPayment = LoanPrograms.calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5});
let conventionalLoanPayment = LoanPrograms.calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180});
let interestOnlyPayment = LoanPrograms.calculateInterestOnlyLoanPayment({principal: 30000, interestRate: 5});
let conventionalLoanPayment = LoanPrograms.calculateConventionalLoanPayment({principal: 30000, interestRate: 5, months: 180});
console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00"
console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24"
10 changes: 5 additions & 5 deletions code/module-08/m08-start/module08_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


interface Loan {
principle: number,
principal: number,
interestRate: number //* Interest rate percentage (eg. 14 is 14%)
}
interface ConventionalLoan extends Loan {
Expand All @@ -18,14 +18,14 @@ interface ConventionalLoan extends Loan {
/* TODO Update the calculateInterestOnlyLoanPayment function. */
function calculateInterestOnlyLoanPayment(loanTerms: Loan): string {
let payment: number;
payment = loanTerms.principle * calculateInterestRate(loanTerms.interestRate);
payment = loanTerms.principal * calculateInterestRate(loanTerms.interestRate);
return 'The interest only loan payment is ' + payment.toFixed(2);
}
/* TODO Update the calculateConventionalLoanPayment function. */
function calculateConventionalLoanPayment(loanTerms: ConventionalLoan): string {
let interest: number = calculateInterestRate(loanTerms.interestRate);
let payment: number;
payment = loanTerms.principle * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
payment = loanTerms.principal * interest / (1 - (Math.pow(1/(1 + interest), loanTerms.months)));
return 'The conventional loan payment is ' + payment.toFixed(2);
}
function calculateInterestRate (interestRate: number): number {
Expand All @@ -37,7 +37,7 @@ function calculateInterestRate (interestRate: number): number {

/* TODO Update the function calls. */

let interestOnlyPayment = calculateInterestOnlyLoanPayment({principle: 30000, interestRate: 5});
let conventionalLoanPayment = calculateConventionalLoanPayment({principle: 30000, interestRate: 5, months: 180});
let interestOnlyPayment = calculateInterestOnlyLoanPayment({principal: 30000, interestRate: 5});
let conventionalLoanPayment = calculateConventionalLoanPayment({principal: 30000, interestRate: 5, months: 180});
console.log(interestOnlyPayment); //* Returns "The interest only loan payment is 125.00"
console.log(conventionalLoanPayment); //* Returns "The conventional loan payment is 237.24"