Skip to content

I think I completely this correctly #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>Open up the console to check your work!</p>

<script src="index.js"></script>
</body>
35 changes: 29 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -4,10 +4,6 @@
/* 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.
*/





// 🏡 Task 1.5: Simple Math
/* To create a monthly mortgage rate calculator, we need to know the number of years in months and the monthly interest rate.

@@ -16,8 +12,6 @@
*/




// 🏡 Task 2: Harder Math
/* Create your calculator! Use the formula in the ReadMe (also below) to run calculations on your numbers. Save the final value into a variable called monthlyRate.

@@ -103,3 +97,32 @@ 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 mortgageCalculator(principal, interestRate, years, creditScore){
const name = "Ally";
let monthlyInterestRate = ( interestRate / 12 )
let periods = ( years * 12 )
let i = monthlyRate

let variableInterestRate = ( monthlyRate * 0.95 )
for (let i = 0; i < 10; i + 0.95) {
console.log(name + ",with an interest rate of" + monthlyInterestRate + "your monthly rate is" + variableInterestRate + "<br>")
}
let n1 = Math.pow((1 + monthlyInterestRate ) **periods )
let numerator = principal * n1 * monthlyInterestRate
let denominator = n1 - 1
let monthlyRate = numerator/denominator

}
if (creditScore > 740 ) { monthlyRate = (monthlyRate * 0.95);
}
else if (creditScore < 660 ) {monthlyRate = (monthlyRate * 1.05);
}
else if (creditScore <= 740 && creditScore >= 660) {monthlyRate = monthlyRate};
}
console.log(name + "your monthly rate is" + monthlyRate)}
}

mortgageCalculator( 200000, 0.05, 30, 700)
}