-
Notifications
You must be signed in to change notification settings - Fork 0
setup assignment and started creating variables #1
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
base: master
Are you sure you want to change the base?
Changes from all commits
934f8d4
1ef77be
d84a245
47b409c
b96b326
86dc4d9
117c801
5a97336
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +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; | ||
| const name = 'Chris'; | ||
|
|
||
|
|
||
|
|
||
|
|
@@ -15,8 +18,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; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome! |
||
|
|
||
|
|
||
| // 🏡 Task 2: Harder Math | ||
|
|
@@ -28,7 +31,10 @@ 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 | ||
| */ | ||
|
|
||
| let numerator = principal*monthlyInterestRate*(Math.pow(1+monthlyInterestRate,periods)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome! |
||
| let denominator = (Math.pow(1+monthlyInterestRate,periods)-1); | ||
| let monthlyRate = numerator/denominator; | ||
| console.log('Monthly Rate:'+ monthlyRate.toFixed(2)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice job! |
||
|
|
||
|
|
||
|
|
||
|
|
@@ -37,7 +43,22 @@ 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() { | ||
| let prin = 200000; | ||
| let iRate = 0.05; | ||
| let yrs= 30; | ||
| const name = 'Chris'; | ||
| let mIrate = iRate/12; | ||
| let per = yrs*12 | ||
| let numer = prin*mIrate*(Math.pow(1+mIrate,per)); | ||
| let denom = (Math.pow(1+mIrate,per)-1); | ||
| let monthlyRate = numer/denom; | ||
| monthlyRate = monthlyRate.toFixed(2); | ||
| return `${name}, your monthly rate is ${monthlyRate}`; | ||
| } | ||
|
|
||
| mortgageCalculator(); | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great work! |
||
|
|
||
|
|
||
|
|
||
|
|
@@ -49,15 +70,43 @@ For example, | |
| mortgageCalculator(2000000, 0.05, 30); <-- should return 1,073.64 | ||
| */ | ||
|
|
||
| mortgageCalculator = (P,I,N) => { | ||
| const name = 'Chris'; | ||
| let mIrate = I/12; | ||
| let per = N*12 | ||
| let numer = P*mIrate*(Math.pow(1+mIrate,per)); | ||
| let denom = (Math.pow(1+mIrate,per)-1); | ||
| let monthlyRate = numer/denom; | ||
| monthlyRate = monthlyRate.toFixed(2); | ||
| return `${monthlyRate}`; | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking good! |
||
|
|
||
|
|
||
|
|
||
| mortgageCalculator(200000,0.05,30); | ||
|
|
||
| // 🏡 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). | ||
|
|
||
| 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. | ||
| */ | ||
| mortgageCalculator = (P,I,N,creditScore) => { | ||
| if(creditScore > 740){ | ||
| I -= (I * .5) / 100; | ||
| }else if(creditScore < 660){ | ||
| I += (I * .5) / 100; | ||
| } | ||
| let mIrate = I/12; | ||
| let per = N*12 | ||
| let numer = P*mIrate*(Math.pow(1+mIrate,per)); | ||
| let denom = (Math.pow(1+mIrate,per)-1); | ||
| let monthlyRate = numer/denom; | ||
| monthlyRate = monthlyRate.toFixed(2); | ||
|
|
||
| return `${monthlyRate}`; | ||
| } | ||
|
|
||
|
|
||
| mortgageCalculator(200000,0.05,30,750); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome! this looks great! |
||
|
|
||
|
|
||
|
|
||
|
|
@@ -77,7 +126,22 @@ For example, variableInterestRate(200000, 0.04, 30) should console.log: | |
| "{Name}, with an interest rate of 0.055, your monthly rate is $1136" | ||
| "{Name}, with an interest rate of 0.06, your monthly rate is $1199" | ||
| */ | ||
|
|
||
| variableInterestRate = (P,I,N,creditScore) => { | ||
| const name = 'Chris'; | ||
| if(creditScore > 740){ | ||
| I -= (I * .5) / 100; | ||
| }else if(creditScore < 660){ | ||
| I += (I * .5) / 100; | ||
| } | ||
| let mIrate = I/12; | ||
| let per = N*12 | ||
| let numer = P*mIrate*(Math.pow(1+mIrate,per)); | ||
| let denom = (Math.pow(1+mIrate,per)-1); | ||
| let monthlyRate = numer/denom; | ||
| monthlyRate = monthlyRate.toFixed(2); | ||
|
|
||
| return `${monthlyRate}`; | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥🔥🔥
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome .. Thank You .. this was a fun one ... had me up late lol |
||
|
|
||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good!