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
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/index.js"
}
]
}
62 changes: 60 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

// 🏡 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.
*/

Task 1 test:

*/
const principal = 200000;
const interestrate = 0.05;
const years = 30;
const name = 'Jim';

/*



Expand All @@ -16,6 +23,10 @@ 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.
*/

const monthlyInterestRate = interestrate / 12;
const periods = years*12;





Expand All @@ -30,6 +41,14 @@ When your math is correct, monthlyRate will equal 1073.64
*/


const numerator = monthlyInterestRate * Math.pow((1+monthlyInterestRate), periods);
const denominator = Math.pow((1+monthlyInterestRate), periods) - 1;

const monthlyrate = principal * (numerator / denominator);






// 🏡 Task 3: Function
Expand All @@ -38,6 +57,12 @@ When your math is correct, monthlyRate will equal 1073.64
If your name is `Oscar` mortgageCalculator() should return "Oscar, your monthly rate is 1073.64"
*/

function mortgageCalculator() {
console.log(name + ", your monthly rate is $" + monthlyrate)
}

mortgageCalculator();




Expand All @@ -49,7 +74,11 @@ For example,
mortgageCalculator(200000, 0.05, 30); <-- should return 1,073.64
*/


function mortgageCalculator(P,I,N) {
console.log(P * (I * Math.pow((1+I),N)) / (Math.pow((1+I), N) -1));
}

mortgageCalculator(200000, .00416667, 360);



Expand All @@ -59,6 +88,23 @@ mortgageCalculator(200000, 0.05, 30); <-- should return 1,073.64
Then, add control flow within your function such that IF creditScore is above 740, interest rate drops by 0.5%, if credit score is below 660, interest rate increases by 0.5% and if credit score is anywhere between 660 and 740 interest rate doesn't change.
*/

function task5mortgageCalculator(P,I,N,creditScore) {
if (creditScore > 740){
I = I - 0.005;
}
if (creditScore < 660){
I = I + 0.005;
}
if (creditScore < 740 && creditScore > 660){
I = I
}

console.log(P * (I * Math.pow((1+I),N)) / (Math.pow((1+I), N) -1));
}

task5mortgageCalculator(principal, monthlyInterestRate, periods, 650);





Expand All @@ -78,6 +124,18 @@ For example, variableInterestRate(200000, 0.04, 30) should console.log:
"{Name}, with an interest rate of 0.06, your monthly rate is $1199"
*/

function variableInterestRate(name, P, I, N){
const periods = N * 12;
I = I - 0.025;
for (let i = 0; i < 10; i++){
I = I + 0.005;
let monthlyInterestRate = I / 12;
let monthlyRate = (P * (monthlyInterestRate * Math.pow((1 + monthlyInterestRate), periods)) / (Math.pow((1 + monthlyInterestRate),periods) -1));
console.log(name + ", with an Interest rate of " + I.toFixed(3) + ", your monthly rate is " + "$" + monthlyRate.toFixed(0))
}
}

variableInterestRate(name, 200000, .04, 30);



Expand Down