Skip to content
Open
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
21 changes: 17 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// 🏡 Task 1: Variables
/* Create variables for principal, interest rate, and years. Assign them the values 200000, 0.05, and 30 respectively. Create another value called name and give it the value of your own name.
*/
let principal = 200000;
let interestRate = 0.05;
let years = 30;
let name = "Deborah Warren";



Expand All @@ -16,7 +20,8 @@ Create a variable called `monthlyInterestRate` and give it the value of interest
Create another variable called `periods` and give it the value of years*12.
*/


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


// 🏡 Task 2: Harder Math
Expand All @@ -28,16 +33,24 @@ Hint #2: you'll need to use the `math` object for parts of this calculation!

When your math is correct, monthlyRate will equal 1073.64
*/



function monthlyRate(){
let numerator = principal*(monthlyInterestRate*Math.pow((1+monthlyInterestRate),periods));
let denominator = (Math.pow((1+monthlyInterestRate),periods)-1);
return 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 mortgageCalculator(){
let bill = name + ", your monthly rate is $" + monthlyRate();
return bill;
}

console.log(mortgageCalculator());



Expand Down