Skip to content

Commit c2f0370

Browse files
committed
I think I completely this correctly
1 parent 9bef544 commit c2f0370

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
</head>
88
<body>
9-
<p>Open up the console to check your work!</p>
109

1110
<script src="index.js"></script>
1211
</body>

index.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
/* 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.
55
*/
66

7-
8-
9-
10-
117
// 🏡 Task 1.5: Simple Math
128
/* To create a monthly mortgage rate calculator, we need to know the number of years in months and the monthly interest rate.
139
@@ -16,8 +12,6 @@
1612
*/
1713

1814

19-
20-
2115
// 🏡 Task 2: Harder Math
2216
/* 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.
2317
@@ -103,3 +97,32 @@ For example, variableInterestRate(200000, 0.04, 30) should console.log:
10397

10498

10599
/* 🏡 Refactor your `variableInterestRate()` function to accept an array of interest rates (make sure to copy and paste as to not lose your work!) */
100+
101+
function mortgageCalculator(principal, interestRate, years, creditScore){
102+
const name = "Ally";
103+
let monthlyInterestRate = ( interestRate / 12 )
104+
let periods = ( years * 12 )
105+
let i = monthlyRate
106+
107+
let variableInterestRate = ( monthlyRate * 0.95 )
108+
for (let i = 0; i < 10; i + 0.95) {
109+
console.log(name + ",with an interest rate of" + monthlyInterestRate + "your monthly rate is" + variableInterestRate + "<br>")
110+
}
111+
let n1 = Math.pow((1 + monthlyInterestRate ) **periods )
112+
let numerator = principal * n1 * monthlyInterestRate
113+
let denominator = n1 - 1
114+
let monthlyRate = numerator/denominator
115+
116+
}
117+
if (creditScore > 740 ) { monthlyRate = (monthlyRate * 0.95);
118+
}
119+
else if (creditScore < 660 ) {monthlyRate = (monthlyRate * 1.05);
120+
}
121+
else if (creditScore <= 740 && creditScore >= 660) {monthlyRate = monthlyRate};
122+
}
123+
console.log(name + "your monthly rate is" + monthlyRate)}
124+
}
125+
126+
mortgageCalculator( 200000, 0.05, 30, 700)
127+
}
128+

0 commit comments

Comments
 (0)