Skip to content
Merged
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
38 changes: 33 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,32 @@ When your math is correct, monthlyRate will equal 1073.64
*/
numerator = MonthlyInterestRate * Math.pow(1 + MonthlyInterestRate, periods);
denominator = Math.pow(1 + MonthlyInterestRate, periods) - 1;
MonthlyPayment = principal * (numerator / denominator)
console.log(MonthlyPayment);
MonthlyRate = principal * (numerator / denominator)
console.log(MonthlyRate);


// 🏡 Task 3: Function
/* Create a function called `mortgageCalculator` that combines all of the steps from task 1 and 2 and returns a sentence "{Name}, your monthly rate is ${monthlyRate}"

If your name is `Oscar` mortgageCalculator() should return "Oscar, your monthly rate is 1073.64"
*/



function MortCal(){

let principal = 200000;
let interestRate = 0.05;
let years = 30;
let name = 'Alex Whitt';

let MonthlyInterestRate = interestRate / 12;
let periods = years * 12;

numerator = MonthlyInterestRate * Math.pow(1 + MonthlyInterestRate, periods);
denominator = Math.pow(1 + MonthlyInterestRate, periods) - 1;
MonthlyRate = principal * (numerator / denominator);
return name + ', your monthly rate is $' + MonthlyRate;
}

console.log(MortCal());


// 🏡 Task 4: Arguments and Parameters
Expand All @@ -54,10 +68,24 @@ If your name is `Oscar` mortgageCalculator() should return "Oscar, your monthly
For example,
mortgageCalculator(2000000, 0.05, 30); <-- should return 1,073.64
*/
function MortCal2(p, i, y, n,s) {

let principal = p;
let interestRate = i;
let years = y;
let name = n;
let credit = s;

let MonthlyInterestRate = interestRate / 12;
let periods = years * 12;

numerator = MonthlyInterestRate * Math.pow(1 + MonthlyInterestRate, periods);
denominator = Math.pow(1 + MonthlyInterestRate, periods) - 1;
MonthlyRate = principal * (numerator / denominator);
return name + ', your monthly rate is $' + MonthlyRate;
}

console.log(MortCal2(200000, 0.05, 30, 'Alex Whitt'));

// 🏡 Task 5: Conditionals
/* Add another paramter to your function called credit score. This parameter will be a number between 0 and 800 (a credit score).
Expand Down